aspose file tools*
The moose likes Other Open Source Projects and the fly likes Multiple log files using Log4j    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Multiple log files using Log4j    " Watch "Multiple log files using Log4j    " New topic
Author

Multiple log files using Log4j

sridhar mangipudi
Greenhorn

Joined: Jun 26, 2008
Posts: 3
Hello,

I want to generate log files based on package structure. Like com.temp.test in test.log ,also I am having a log file at application like app.log .

This is my requirement what has been logged in test.log should not be logged in app.log.This is my log4j.properties file.

# Log4j configuration file.
# Available levels are DEBUG, INFO, WARN, ERROR, FATAL

# Default logger
log4j.rootLogger=DEBUG, PFILE
log4j.logger.com.temp.test=DEBUG,TEST
#
# PFILE is the primary log file
log4j.appender.PFILE=org.apache.log4j.RollingFileAppender
log4j.appender.PFILE.File=./App.log
log4j.appender.PFILE.MaxFileSize=5120KB
log4j.appender.PFILE.MaxBackupIndex=10
#log4j.appender.PFILE.Threshold=DEBUG
log4j.appender.PFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.PFILE.layout.ConversionPattern=%p %d[%l][%C] %m%n
#log4j.appender.PFILE.layout.ConversionPattern=%p %d %m%n

log4j.appender.TEST=org.apache.log4j.RollingFileAppender
log4j.appender.TEST.File=./test.log
log4j.appender.TEST.MaxFileSize=5120KB
log4j.appender.TEST.MaxBackupIndex=10
log4j.appender.TEST.layout=org.apache.log4j.PatternLayout
log4j.appender.TEST.layout.ConversionPattern=%p %d[%l][%C] %m%n

Can youu help me!!!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10091
    
164

This is my requirement what has been logged in test.log should not be logged in app.log


I dont know how this can be done using log4j.properties file. But if you use log4j.xml file, then you can specify "additivity=false" attribute to your loggers.


[My Blog] [JavaRanch Journal]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple log files using Log4j