Method from org.apache.jorphan.logging.LoggingManager Detail: |
public static synchronized LoggingManager getLogManager() {
return logManager;
}
|
public static Logger getLoggerFor(String category) {
return Hierarchy.getDefaultHierarchy().getLoggerFor(category);
}
Get the Logger for a class. |
public static Logger getLoggerForClass() {
String className = getCallerClassName();
return Hierarchy.getDefaultHierarchy().getLoggerFor(removePrefix(className));
}
Get the Logger for a class - no argument needed because the calling class
name is derived automatically from the call stack. |
public static Logger getLoggerForShortName(String category) {
return Hierarchy.getDefaultHierarchy().getLoggerFor(removePrefix(category));
}
Get the Logger for a class. |
public static void initializeLogging(Properties properties) {
synchronized(LoggingManager.class){
if (logManager == null) {
logManager = new LoggingManager();
}
}
setFormat(properties);
// Set the top-level defaults
setTarget(makeWriter(properties.getProperty(LOG_FILE, "jmeter.log"), LOG_FILE)); //$NON_NLS-1$
setPriority(properties.getProperty(LOG_PRIORITY, "INFO"));
setLoggingLevels(properties);
// now set the individual categories (if any)
setConfig(properties);// Further configuration
}
Initialise the logging system from the Jmeter properties. Logkit loggers
inherit from their parents.
Normally the jmeter properties file defines a single log file, so set
this as the default from "log_file", default "jmeter.log" The default
priority is set from "log_level", with a default of INFO |
public static String removePrefix(String name) {
if (name.startsWith(PACKAGE_PREFIX)) { // remove the package prefix
name = name.substring(PACKAGE_PREFIX.length());
}
return name;
}
Removes the standard prefix, i.e. "org.apache.". |
public static void setLoggingLevels(Properties appProperties) {
Iterator props = appProperties.keySet().iterator();
while (props.hasNext()) {
String prop = (String) props.next();
if (prop.startsWith(LOG_PRIORITY + ".")) //$NON_NLS-1$
// don't match the empty category
{
String category = prop.substring(LOG_PRIORITY.length() + 1);
setPriority(appProperties.getProperty(prop), category);
}
if (prop.startsWith(LOG_FILE + ".")) { //$NON_NLS-1$
String category = prop.substring(LOG_FILE.length() + 1);
String file = appProperties.getProperty(prop);
setTarget(new WriterTarget(makeWriter(file, prop), getFormat()), category);
}
}
}
Handle LOG_PRIORITY.category=priority and LOG_FILE.category=file_name
properties. If the prefix is detected, then remove it to get the
category. |
public static void setPriority(String p) {
setPriority(Priority.getPriorityForName(p));
}
|
public static void setPriority(Priority priority) {
Hierarchy.getDefaultHierarchy().setDefaultPriority(priority);
}
Set the default logging priority. |
public static void setPriority(String priority,
String category) {
setPriority(Priority.getPriorityForName(priority), category);
}
Set the logging priority for a category. |
public static void setPriority(Priority priority,
String category) {
Hierarchy.getDefaultHierarchy().getLoggerFor(category).setPriority(priority);
}
Set the logging priority for a category. |
public static void setPriorityFullName(String priority,
String fullName) {
setPriority(Priority.getPriorityForName(priority), removePrefix(fullName));
}
Set the logging priority for a category. |
public 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);
}
Sets the default log target from the parameter. The existing target is
first closed if necessary. |
public static void setTarget(LogTarget target,
String category) {
Logger logger = Hierarchy.getDefaultHierarchy().getLoggerFor(category);
logger.setLogTargets(new LogTarget[] { target });
}
Set the logging target for a category. |