| java.lang.Object org.mmbase.util.logging.Logging
Logging | public class Logging (Code) | | With this class the logging is configured and it supplies the `Logger' objects.
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.getName());
public static void main(String[] args) {
log.debug("start");
log.info("Entering application.");
log.setPriority(Level.TRACE);
if (log.isDebugEnabled()) {
log.debug("debug een");
log.trace("trace twee");
}
log.info("info");
log.service("service");
Logging.shutdown();
}
}
author: Michiel Meeuwissen version: $Id: Logging.java,v 1.44 2007/06/21 16:17:21 michiel Exp $ |
Field Summary | |
final public static String | PAGE_CATEGORY The category for logging info about pages (like stop / start). |
PAGE_CATEGORY | final public static String PAGE_CATEGORY(Code) | | The category for logging info about pages (like stop / start). Also if pages take the
initiative for logging themselves they should log below this category.
since: MMBase-1.7 |
applicationStacktrace | public static String applicationStacktrace()(Code) | | since: MMBase-1.8 |
configure | public static void configure(ResourceLoader rl, String configFile)(Code) | | Configure the logging system.
Parameters: configFile - Path to an xml-file in which is describedwhich class must be used for logging, and how this will beconfigured (typically the name of another configuration file). |
configureClass | public static void configureClass(String configuration)(Code) | | Calls the 'configure' static method of the used logging class,
or does nothing if it doesn't exist. You could call this method
if you want to avoid using 'configure', which parses an XML file.
|
getLoggerInstance | public static Logger getLoggerInstance(String s)(Code) | | After configuring the logging system, you can get Logger instances to log with.
Parameters: s - A string describing the `category' of the Logger. This is a log4j concept. |
getLoggerInstance | public static Logger getLoggerInstance(Class> cl)(Code) | | Most Logger categories in MMBase are based on class name.
since: MMBase-1.6.4 |
getMachineName | public static String getMachineName()(Code) | | since: MMBase-1.8 |
getResourceLoader | public static ResourceLoader getResourceLoader()(Code) | | Logging is configured with a log file. This method returns the File which was used.
|
setMachineName | public static void setMachineName(String mn)(Code) | | since: MMBase-1.8 |
shutdown | public static void shutdown()(Code) | | If the configured Logger implements a shutdown static method,
it will be called. (the log4j Category does).
|
stackTrace | public static String stackTrace()(Code) | | Returns the stacktrace of the current call. This can be used to get a stacktrace
when no exception was thrown and my help determine the root cause of an error message
(what class called the method that gave the error message.
since: MMBase-1.7 |
stackTrace | public static String stackTrace(int max)(Code) | | since: MMBase-1.7 |
stackTrace | public static String stackTrace(Throwable e)(Code) | | Returns the stacktrace of an exception as a string, which can
be logged handy. Doing simply e.printStackTrace() would dump
the stack trace to standard error, which with the log4j
implementation will appear in the log file too, but this is a
little nicer.
It is also possible to call 'error' or 'fatal' with an extra argument.
Parameters: e - the Throwable from which the stack trace must be stringified. |
stackTrace | public static String stackTrace(Throwable e, int max)(Code) | | Also returns a stringified stack trace to log, but no deeper than given max.
since: MMBase-1.7 |
|
|