Home / Tech Trends

log4j configuration file

time:2025-04-18 15:01:28 Tech Trends

 log4j file name configuration

log4j supports two configuration file formats, one is an XML file and the other is a Java feature file (key = value). The configuration is as follows:

1. Configure the root logger with the following syntax: log4j.rootLogger = [level], appenderName1, appenderName2, .... The level is the log output level, which has five levels: FATAL, ERROR, WARN, INFO, and DEBUG.

2. Configure the log output destination Appender, and its syntax is log4j.appender.appenderName = fully.qualified.name.of.appender.class. Among them, Log4j provides the following appenders: ConsoleAppender, FileAppender, DailyRollingFileAppender (generates a log file every day), RollingFileAppender (generates a new file when the file size reaches a specified size), WriterAppender (sends log information in a streaming format to any specified location).

3. Configure the format (layout) of log information, and the syntax is as follows: log4j.appender.appenderName.layout = fully.qualified.name.of.layout.class. Among them, Log4j provides the following layouts: HTMLLayout (layout in the form of HTML table), PatternLayout (you can flexibly specify the layout mode), SimpleLayout (contains the level and information string of log information), TTCCLayout (contains the time, thread, category, etc. of the log).

《log4j configuration file》 This does not represent the views of this website. If there is any infringement, please contact us to delete it.

Ranking

Digital Insights