Page tree
Skip to end of metadata
Go to start of metadata

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 file which defines which log configuration should be used. The variable for log4j is DAS_LOG4J_CONF.

export DAS_LOG4J_CONF=foo
-> conf/

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 Levels

Log4j hierarchy

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.

Logger levels
TRACEThe TRACE Level designates finer-grained informational events than the DEBUG.
DEBUGThe DEBUG Level designates fine-grained informational events that are most useful to debug an application.
INFOThe INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
WARNThe WARN level designates potentially harmful situations.
ERRORThe ERROR level designates error events that might still allow the application to continue running.
FATALThe 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. = INFO

to = DEBUG

If Hadoop logger levels are too detailed and spams the log with useless information, making a change to give less details is helpful. = INFO

to = WARN

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.

Example 1

The SMTP Appender sends an email through SMTP for each logged message. This configuration emails any log message that is an error or higher.
log4j.appender.mail.layout.ConversionPattern=Example 2:

Example 2

Rotating Logs: You can move and compress logs to the /var/log/backup directory for daily archiving.

See Rotating Datameer Logs


The PatternLayout part of the standard log4j distribution lets you specify the output format according to string conversion patterns.


ConversionPattern=%-5p %d [%t]: %m%n

%-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.

  • No labels