public class Logging extends Object
For example:
import org.mmbase.util.logging.Logging;
import org.mmbase.util.logging.Logger;
import org.mmbase.util.logging.Level;
public class test {
static {
Logging.configure("log.xml");
}
static Logger log = Logging.getLoggerInstance(test.class);
public static void main(String[] args) {
log.debug("start");
log.info("Entering application.");
log.setLevel(Level.TRACE);
if (log.isDebugEnabled()) {
log.debug("debug een");
log.trace("trace twee");
}
log.info("info");
log.service("service");
Logging.shutdown();
}
}
| Modifier and Type | Field and Description |
|---|---|
static String |
PAGE_CATEGORY
The category for logging info about pages (like stop / start).
|
| Modifier and Type | Method and Description |
|---|---|
static String |
applicationStacktrace() |
static String |
applicationStacktrace(Throwable e) |
static void |
configure(ResourceLoader rl,
String configFile)
Configure the logging system.
|
static void |
configureClass(String configuration)
Calls the 'configure' static method of the used logging class,
or does nothing if it doesn't exist.
|
static Map<String,String> |
getInitParameters() |
static Logger |
getLoggerInstance(Class<?> cl)
Most Logger categories in MMBase are based on class name.
|
static Logger |
getLoggerInstance(String s)
After configuring the logging system, you can get Logger instances to log with.
|
static String |
getMachineName() |
static MDC |
getMDC()
MDC stands for mapped diagnostic contexts See also log4j.MDC
|
static ResourceLoader |
getResourceLoader()
Logging is configured with a log file.
|
static boolean |
isEnabled(Level l,
Logger log)
Utility method for dynamicly checking the 'enabled'ness of a logger on a given level.
|
static void |
log(Level l,
Logger log,
String mes)
Utility method for dynamicly determin the level of logging.
|
static void |
setMachineName(String mn) |
static void |
shutdown()
If the configured Logger implements a shutdown static method,
it will be called.
|
static String |
stackTrace()
Returns the stacktrace of the current call.
|
static String |
stackTrace(int max) |
static String |
stackTrace(Throwable e)
Returns the stacktrace of an exception as a string, which can
be logged handy.
|
static String |
stackTrace(Throwable e,
int max)
Also returns a stringified stack trace to log, but no deeper than given max.
|
public static final String PAGE_CATEGORY
public static String getMachineName()
public static void setMachineName(String mn)
public static void configure(ResourceLoader rl, String configFile)
configFile - Path to an xml-file in which is described
which class must be used for logging, and how this will be
configured (typically the name of another configuration file).public static void configureClass(String configuration)
public static ResourceLoader getResourceLoader()
public static Logger getLoggerInstance(String s)
s - A string describing the `category' of the Logger. This is a log4j concept.public static MDC getMDC()
public static Logger getLoggerInstance(Class<?> cl)
public static void shutdown()
public static String stackTrace()
public static String stackTrace(int max)
public static String stackTrace(Throwable e)
e - the Throwable from which the stack trace must be stringified.public static String stackTrace(Throwable e, int max)
public static String applicationStacktrace()
public static void log(Level l, Logger log, String mes)
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}