aspose file tools*
The moose likes Other Open Source Projects and the fly likes customize appenders within rootCategory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "customize appenders within rootCategory" Watch "customize appenders within rootCategory" New topic
Author

customize appenders within rootCategory

Mike Corriston
Greenhorn

Joined: Jan 22, 2004
Posts: 3
Hello,
I'm trying to figure out a way to customize an appender without having to create a new Category for it. I have a console appender created off the rootCategory that logs all levels debug and up. I want to have another appender, a fileAppender, created off the rootCategory as well that is assigned the error priority. The formatting of this will use file name and line numbers. I only want line number formatting for errors since its a cpu instensive option. The way I have it now is presented in the config file below:
log4j.rootCategory=DEBUG, A1
# A1 is a ConsoleAppender
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-5p [%t] - %m%n
#########################################################
log4j.category.com.pge.fileLog=ERROR, A2
log4j.additivity.com.pge.fileLog=false
# A2 is a DailyRollingFileAppender
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.file=logfile.log
log4j.appender.A2.datePattern='.'yyyy-MM-dd
log4j.appender.A2.append=true
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5p %F:%L %d{MMM dd yyyy HH:mm:ss} - %m%n
So the only way I know to have the two appenders work independant of each other is to place them under separate categories. So if I can get one logging object that writes info messages to the console and error messages to the file, that would be ideal. I don't want one appender logging console when I'm wanting to log to file and vice versa. But what this means is in my code I have to load two different loggers:
Logger conLog = SMIPLogger.getStandardLogger();
Logger fileLog = SMIPLogger.getErrorLogger();
Anybody have any ideas/suggestions on this? Thanks.
- MIke
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: customize appenders within rootCategory