| | |
|
|
|
Logging and tracing
Zero applications use the java.util.logging package for log and trace functions. Log and trace configurations are specified in the <appHome>/config/logging.properties file. This file is read and applied automatically by Zero if it is present.
Java logging consists of two principle components: Loggers (sources) and Log Handlers (sinks). Verbosity of each of these components may be controlled through log Level settings.
Default log and trace settings
Default settings for Zero applications use a "log" and console for important messages and a "trace" to include detailed messages. Specifically:
- Logs and console contain messages of level
INFO and above. Logs are written to a rotating output file in the <appHome>/logs directory; error-log-0 is the most recent file.
- Trace contains messages of level
INFO and above. Trace is also written to a rotating output file; <appHome>/logs/trace-log-0 is the most recent file. Trace includes Java exception stack trace details.
Loggers
Loggers are instantiated within application and platform code. For example, in Java code:
Logger logger = Logger.getLogger("fully.qualified.class.name");
Loggers source LogRecords via Logger APIs or Zero's LogHelper API.
Level settings
Two log levels are compared to determine whether a logging API invocation sources a LogRecord:
- Logger level -- Level associated with the logger; specified in
logging.properties
- API-invocation level -- Level specified in the API invocation (e.g.
LogHelper.log(logger, Level.WARNING, ...) )
A logging API invocation sources a LogRecord only if the Logger level is equal or greater than the API-invocation level.
For example, the default Logger level for all Loggers is set in logging.properties as follows:
.level=INFO
One could also set Logger levels for specific Loggers by specifying the package or fully-qualified class name. For example:
# Applies to all loggers under package "fully.qualified"
fully.qualified.level=INFO
# Applies to the class "fully.qualified.class.name"
fully.qualified.class.name.level=INFO
Log handlers
Log handlers are specified in the logging.properties file. Each handler has an associated log level that controls which LogRecords are handled; others are ignored.
# This log handler handles only LogRecords at level WARNING and above;
# Others are ignored
zero.core.logging.LogHandler.level=WARNING
Logging from Groovy scripts
See the Groovy handlers page for details.
Access Logging
Zero provides the ability to log all http requests via access logging. By default access logging is disabled. To enable access logging add the following line tothe <apphome>/config/zero.config file:
[/config]
accessLogging=true
When enabled the <apphome>/logs/access-log will be created. Access log entries will have the format:
<hostname or IP> [<local time>] <http method> <Request URI> <status code> <bytecount>
|
|
r13 - 26 Oct 2007 - 09:56:26 - cjthorne
|
|
|
| | |