本文整理汇总了Java中org.apache.log.Hierarchy类的典型用法代码示例。如果您正苦于以下问题:Java Hierarchy类的具体用法?Java Hierarchy怎么用?Java Hierarchy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Hierarchy类属于org.apache.log包,在下文中一共展示了Hierarchy类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* initializes the log system using the logfile argument
*
* @param logFile file for log messages
*/
public void init(String logFile)
throws Exception
{
/*
* make our FileTarget. Note we are going to keep the
* default behavior of not appending...
*/
FileTarget target = new FileTarget( new File( logFile),
false,
new VelocityFormatter("%{time} %{message}\\n%{throwable}" ) );
/*
* use the toString() of RuntimeServices to make a unique logger
*/
logger = Hierarchy.getDefaultHierarchy().getLoggerFor( rsvc.toString() );
logger.setPriority( Priority.DEBUG );
logger.setLogTargets( new LogTarget[] { target } );
}
示例2: setTarget
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* Sets the default log target from the parameter. The existing target is
* first closed if necessary.
*
* @param targetFile
* (Writer)
*/
private static synchronized void setTarget(Writer targetFile) {
if (target == null) {
target = getTarget(targetFile, getFormat());
isTargetSystemOut = isWriterSystemOut;
} else {
if (!isTargetSystemOut && target instanceof WriterTarget) {
((WriterTarget) target).close();
}
target = getTarget(targetFile, getFormat());
isTargetSystemOut = isWriterSystemOut;
}
Hierarchy.getDefaultHierarchy().setDefaultLogTarget(target);
}
示例3: addLogTargetToRootLogger
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* Add logTargets to root logger
* FIXME What's the clean way to add a LogTarget afterwards ?
* @param logTargets LogTarget array
*/
public static void addLogTargetToRootLogger(LogTarget[] logTargets) {
LogTarget[] newLogTargets = new LogTarget[logTargets.length+1];
System.arraycopy(logTargets, 0, newLogTargets, 1, logTargets.length);
newLogTargets[0] = target;
Hierarchy.getDefaultHierarchy().getRootLogger().setLogTargets(newLogTargets);
}
示例4: getLoggerForClass
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* Get the Logger for a class - no argument needed because the calling class
* name is derived automatically from the call stack.
*
* @return Logger
*/
public static Logger getLoggerForClass() {
String className = new Exception().getStackTrace()[1].getClassName();
return Hierarchy.getDefaultHierarchy().getLoggerFor(removePrefix(className));
}
示例5: getLoggerFor
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* Get the Logger for a class.
*
* @param category - the full name of the logger category
*
* @return Logger
*/
public static Logger getLoggerFor(String category) {
return Hierarchy.getDefaultHierarchy().getLoggerFor(category);
}
示例6: getLoggerForShortName
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* Get the Logger for a class.
*
* @param category - the full name of the logger category, this will have the prefix removed.
*
* @return Logger
*/
public static Logger getLoggerForShortName(String category) {
return Hierarchy.getDefaultHierarchy().getLoggerFor(removePrefix(category));
}
示例7: setPriority
import org.apache.log.Hierarchy; //导入依赖的package包/类
/**
* Set the logging priority for a category.
*
* @param priority - e.g. Priority.DEBUG
* @param category - string containing the category
*/
public static void setPriority(Priority priority, String category) {
Hierarchy.getDefaultHierarchy().getLoggerFor(category).setPriority(priority);
}