go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  How to load log4j.properties file?
 
Subject: How to load log4j.properties file?
Author: EricJ
In response to: Log4j.properties file
Posted on: 09/07/2013 06:41:47 AM

Two basic ways:

1) via system property -Dlog4j.properties=<path_to_file>

2) Default to resource folder <resources>/log4j.properties



 

> On 09/07/2013 06:34:47 AM EricJ wrote:


#
#  Define parameters
#
mycompany.log.dir=C:/tmp
mycompany.log.file=slf4j.log


# Root logger option
log4j.rootLogger=INFO, CONSOLE, FILE

#
# console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.Target=System.err
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}.%M@%L] - %m%n

#
# file
#
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.Threshold=DEBUG
log4j.appender.FILE.File=${mycompany.log.dir}/${mycompany.log.file}
log4j.appender.FILE.MaxFileSize=1MB
log4j.appender.FILE.MaxBackupIndex=1
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n

 
# fine tune each package
log4j.logger.com.mycompany.example=TRACE





References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.