To output system messages (log output), the PPM server uses the standard Java interface log4J. log4J is a flexible framework for controlling output of Java application messages using various media (output channels). The log4J interface is configured either in an XML or property file. It consists of three components: logger (collection), layout (formatting), and appender (output)
PPM extracts the log4J configuration from a property file.
Logger
The Java application passes its messages to a certain logger (collector) that processes them depending on their type. Messages can be of these types (log levels): ALL, TRACE, INFO, WARN, ERROR, FATAL, OFF.
Log level |
Description |
ALL |
Turns on all logging. |
TRACE |
Very detailed runtime messages, often combined with output of complete error states of the application |
DEBUG |
Comprehensive runtime message, often describing the internal state of the application |
INFO |
General information or warnings |
WARN |
Information about application states that are not critical for runtime, e.g., missing or wrong configurations |
ERROR |
Errors often leading to cancelation of the active component |
FATAL |
Errors leading to abortion of the application, e.g., lack of resources |
OFF |
No log output |
The following line defines a logger in the log4J configuration file:
<logger name>=<log level>,<appender name 1>, ... , <Appender name n>
Logger names are case-sensitive. The names form a hierarchical structure. The root element is the root logger. The hierarchy levels are separated by a period (.). The higher hierarchy level passes on its configuration to the lower level, which is then overwritten by specific settings.
The table below illustrates the inheritance hierarchy:
Logger name |
Assigned log level |
Inherited log level |
log4j.rootLogger |
INFO |
none |
log4j.logger.LOG |
DEBUG |
INFO |
log4j.logger.LOG.SRV |
ERROR |
INFO |
Appender
The logger passes the messages to the appenders (recipients) that output the messages in a certain form (layout). Appenders differ in terms of their output, e.g.:
PPM appender example |
Description |
console |
Messages are output on the console |
logFile |
Messages are written to a file |
errorFile |
Error messages are written to a file |
The following line defines a logger in the log4J configuration file:
log4j.appender.<name>=<class name>
You can specify multiple appenders for a logger. All appenders of a logger output the messages based on their configuration.
Some appenders write the messages to the log system of the operating system, send them as e-mails, or send them via the network to a particular log server.
Layout
You can use styles to specify the output format. These styles are specified for the relevant appender. Key placeholders for a style include:
Placeholder |
Description |
%c |
Category/logger (corresponds to the PPM module) |
%C |
Class name, fully qualified |
%d |
Date, e.g., %d{HH:mm:ss,SSS} |
%F |
File name |
%L |
Line number |
%m |
The message itself |
%M |
Name of method |
%n |
Line break |
%p |
Priority, level (INFO, WARN, ERROR, etc.) |
%t |
Name of thread |
%throwable{0} |
Stacktrace output is suppressed. |
Example
The style [%t] %-5p %C - %m%n generates the following output:
[main] INFO org.apache.log4j.Action - The process was started