Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

customizing java logging configuration file

Status
Not open for further replies.

rsst

Programmer
May 25, 2005
6
0
0
US
I would like to redirect the log messages coming from different applications to different files, specifying the file names in the configuration file, instead of in my program itself. The configuration file should look some thing like this...


# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
com.xyz.foo.level = SEVERE

com.xyz.foo.file = file1.log
com.xyz.abc.file = file2.log

Pl. suggest me a way

 
Using log4j, something like this, in a log4j.properties file on the classpath, would give you two unlimited length log files.
Code:
log4j.logger.com.xyz.foo=FATAL, A
log4j.logger.com.xyz.abc=FATAL, B

# Configure appender 
log4j.appender.A=org.apache.log4j.FileAppender
log4j.appender.A.File=LogFile1.log

log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.appender.B=org.apache.log4j.FileAppender
log4j.appender.B.File=LogFile2.log

log4j.appender.B.layout=org.apache.log4j.PatternLayout
log4j.appender.B.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

There is no 'severe' level in log4j, but I believe you can 'roll-your-own' custom levels.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top