Log4j PropertiesThe log4j.properties file is a log4j configuration file which stores properties in key-value pairs. The log4j properties file contains the entire runtime configuration used by log4j. This file will contain log4j appenders information, log level information and output file names for file appenders. By default, the LogManager searches for a file named log4j.properties in the CLASSPATH. log4j.properties Syntax:
Let's see the syntax of log4j.properties file for an appender X: log4j.properties Example:With the help of the above syntax, we define the following in log4j.properties file:
It is important to note that log4j supports UNIX-style variable substitution, such as ${variableName}. log4j.properties - Other Examples:
In this example, all logging will be redirected to your console:
In this example, all Logging information will be redirected to your specified log file:
In this example, all logging will be redirected to both console and log file: Next TopicLog4j XML |