2 Minutes To Code (β Version)

Log4j - 2 minute tutorial

Console Logging : How to configure log4j to write logs on console using log4j.properties

The log4j.properties file given below will set up logging on console.

In line no. 1 , we are initializing thr root logger with log level INFO and giving it the name loggerId.

In line no. 2 we are setting an appender for rootLogger using its name loggerId. The appender is ConsoleAppender, which logs messages to console.

In line no.3 , we are seeting the layout for the log statements.

log4j.rootLogger=INFO, loggerId