|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.trace.TraceLoggerFactory
public final class TraceLoggerFactory
Factory class used to manage trace loggers and handlers.
Nested Class Summary | |
---|---|
static class |
TraceLoggerFactory.ForkHandler
Implements a 'fork' trace handler. |
static class |
TraceLoggerFactory.NullHandler
Implements a 'null' handler. |
static class |
TraceLoggerFactory.StderrHandler
Implements the 'stderr' trace handler This handler directs all trace to System.err
|
static class |
TraceLoggerFactory.StdoutHandler
Implements a 'stdout' trace handler. |
Field Summary | |
---|---|
static String |
DEFAULT_HANDLER_NAME
The name of the default handler. |
Method Summary | |
---|---|
Handler |
createHandler(String handlerName,
String descriptorStr)
Create/update a handler. |
Logger |
createLogger(String loggerName,
String levelStr,
String handlersStr)
Create/update a logger. |
Handler |
getHandler(String handlerName)
Get a handler. |
static TraceLoggerFactory |
getInstance()
Return the singleton log factory instance. |
Logger |
getLogger(String loggerName,
boolean create)
Get a logger. |
void |
registerWatcher(Handler handler)
Install a trace watcher. |
static void |
setDefaultHandler(Handler handler)
Set the default handler. |
static void |
setFormatter(Formatter formatter)
Set the trace formatter. |
void |
setHandler(String handlerName,
Handler handler)
Set a handler. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_HANDLER_NAME
Method Detail |
---|
public static TraceLoggerFactory getInstance()
public static void setDefaultHandler(Handler handler)
The handler set using this method is used as the default handler. If not set using this method, then the logger factory instantiates the default handler using the "nv.logger.defaulthandler" application property. If the "nv.logger.defaulthandler" property is not set, then the default handler is created using "stdout://level=finest" logger descriptor.
public static void setFormatter(Formatter formatter)
formatter
- The formatter to use.
This method sets the trace formatter to attach to handlers attached to loggers
created using this logger factory. The factory uses the platform's default
trace handler - TraceFormatter
- in case a user supplied formatter is
not supplied using this method.
public final Handler createHandler(String handlerName, String descriptorStr)
handlerName
- The name of the handler to create.descriptorStr
- This parameter contains a structured string of the
form [handler type]://prop=name&prop=name&...&prop=name
that describes what and how to create the handler. The handler type
specifies the type of handler to create. The supported handler types are
'stdout', 'stderr', 'memory', 'file' and 'network'. The handler type
defines the properties that can be specified in the remaining portion of
the descriptor. For example, to specify a file handler that uses 5 log
files with a maximum size of 100000 bytes per file with names starting
with test.log in append mode, use the following descriptor:Currently, fork and history handlers cannot be created using this method
This method creates a new handler with the supplied name using the supplied descriptor. Refer to the descriptorStr parameter documentation on how the parameter is used in the creation of the handler. In case the handler with the supplied name already exists, this method will replace the existing handler with the new handler.
Upon class initialization, this class creates a 'default' handler using 'stdout://level=finest' unless the nv.logger.defaulthandler application property is set and contains a valid handler descriptor in which case the value set in the property is used to create the default handler. The default handler is used during the creation of a logger with no specified handlers.
public final void setHandler(String handlerName, Handler handler)
handlerName
- The name of the handler to set.handler
- The handler to set.
This method sets/replaces a handler of the specified name.
public final Handler getHandler(String handlerName)
handlerName
- The name of the handler to get.
This method returns a handler with the specified name. A value of null is returned in case a handler with the specified name could not be found.
public final Logger createLogger(String loggerName, String levelStr, String handlersStr)
loggerName
- The name of the logger to create.levelStr
- In order to determine the level to be set for the
logger being created, this method first checks if there exists the
'Level.FINEST
handlersStr
- This string (a comma separated set of string names)
specifies the names of the handlers to associated with the logger.
In case this parameter is null, the method checks if there exists the
'createHandler(java.lang.String, com.neeve.util.UtlPropsDescriptor)
. Once the appropriate handler string has been
selected, the method associates handlers corresponding to the names in
this string. Names for which there do not exist any handlers are ignored.
This method creates a new logger with the supplied name using the supplied level and handler names to associate with it. Refer to the levelStr and handlersStr parameter documentation on how those parameters are used in the association of level and handlers with the newly created logger. In case the logger with the supplied name already exists, this method will replace the existing level and handlers with the new set.
public final Logger getLogger(String loggerName, boolean create)
loggerName
- The name of the logger to get.create
- Specifies in a new logger should be created in case
a logger with the specified name cannot be found. In this case,
the new logger is created using createLogger(loggerName, null, null)
This method returns a logger with the specified name. In case the logger is not present and the user requests for creation, a new logger is created using createLogger(loggerName, null, null) and returned to the user.
public final void registerWatcher(Handler handler)
handler
- The watcher handler.
This method enables a user to install a global trace watcher. If installed all trace flowing through the system is published to the trace watcher handler in addition to the regular trace handlers.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |