Log4j is a popular logging package written in Java. One of its distinctive features is the notion of inheritance in loggers. Using a logger hierarchy it is possible to control which log statements are output at arbitrary granularity. This helps reduce the volume of logged output and minimize the cost of logging.
One of the advantages of the log4j API is its manageability. Once the log statements have been inserted into the code, they can be controlled with configuration files. They can be selectively enabled or disabled, and sent to different and multiple output targets in user-chosen formats. The log4j package is designed so that log statements can remain in shipped code without incurring a heavy performance cost.
Find more information about log4j at the Apache website.
Log4j in Datameer
A variable needs to be set in the
das-env.sh file which defines which log configuration should be used. The variable for log4j is
Log4j is useful when administrating logs since you have control of logger levels, appenders, and layouts.
To access log4j files in Datameer:
After changing any of these properties, Datameer needs to be restarted.
Logger names are case-sensitive and they follow the hierarchical naming rule:
A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no ancestors between itself and the descendant logger.
Each logger is assigned a printing level depending on how much information should be collected.
|TRACE||The TRACE Level designates finer-grained informational events than the DEBUG.|
|DEBUG||The DEBUG Level designates fine-grained informational events that are most useful to debug an application.|
|INFO||The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.|
|WARN||The WARN level designates potentially harmful situations.|
|ERROR||The ERROR level designates error events that might still allow the application to continue running.|
|FATAL||The FATAL level designates very severe error events that will presumably lead the application to abort.|
If there is a problem with the Hadoop client accessing the cluster, making the Hadoop logger more detailed could give helpful information.
If Hadoop logger levels are too detailed and spams the log with useless information, making a change to give less details is helpful.
For more information on printing levels see Apache Class Levels.
Log4j allows logging requests to print to multiple destinations. These output destinations are called appenders.
The SMTP Appender sends an email through SMTP for each logged message. This configuration emails any log message that is an error or higher.
Rotating Logs: You can move and compress logs to the
/var/log/backup directory for daily archiving.
The PatternLayout part of the standard log4j distribution lets you specify the output format according to string conversion patterns.
%-5p = The type of log level
%d = Date
%t = Thread that generated the logging event
%m = Output of the application supplied message
%n = Outputs the platform dependent line separator character or characters.