Skip to content

Instantly share code, notes, and snippets.

@jiahut
Created August 9, 2018 10:01
Show Gist options
  • Save jiahut/d68481a9b6c300a8fa04264b3e4cbf00 to your computer and use it in GitHub Desktop.
Save jiahut/d68481a9b6c300a8fa04264b3e4cbf00 to your computer and use it in GitHub Desktop.
# log4j.configuration=log4j.properties Use this system property to specify the name of a Log4J configuration file. If not specified, the default configuration file is log4j.properties.
# log4j.rootCategory=priority [, appender]*
# Set the default (root) logger priority. log4j.logger.logger.name=priority Set the priority for the named logger and all loggers hierarchically lower than, or below, the named logger. logger.name corresponds to the parameter of LogFactory.getLog(logger.name), used to create the logger instance. Priorities are: DEBUG, INFO, WARN, ERROR, or FATAL.
#Log4J understands hierarchical names, enabling control by package or high-level qualifiers: log4j.logger.org.apache.component=DEBUG will enable debug messages for all classes in both org.apache.component and org.apache.component.sub. Likewise, setting log4j.logger.org.apache.component=DEBUG will enable debug message for all 'component' classes, but not for other Jakarta projects.
# log4j.appender.appender.Threshold=priority
log4j.rootCategory=INFO, stdout, Application
# file logger
log4j.appender.Application=org.apache.log4j.RollingFileAppender
log4j.appender.Application.File=logfile.txt
log4j.appender.Application.Append=false
log4j.appender.Application.layout=org.apache.log4j.PatternLayout
log4j.appender.Application.layout.ConversionPattern=%-5p [%t]: %m%n
# Control the maximum log file size
log4j.appender.Application.MaxFileSize=100KB
# Archive log files (one backup file here)
log4j.appender.Application.MaxBackupIndex=1
# stdout logger
log4j.category.stdout=TRACE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L): %m%n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment