Logging debug and error messages to separate files
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bindiya_Narayan
Posted On:   Tuesday, January 7, 2003 07:46 AM

Hello, I have a question on log4j.properties . Pls..Pls help me out... I want to log all debug statements to debug.txt all error messages to error.txt and all fatal error messages to fatal.txt. I have set up my property file as follows : # Turn log4j debugging on # log4j.debug = true ###################################### # Configure the log4j logging system ###################################### # Set the root output level and appenders log4j.rootCategory=, FileAppender1, FileAppender2 log4j.category.CustRequestExtractor.class=debug FileAppender1 log4j.category.CustRequestExtractor.class=ERROR FileAppender2 log4j.ap   More>>

Hello,

I have a question on log4j.properties . Pls..Pls help me out...

I want to log all debug statements to debug.txt all error messages to error.txt and all fatal error messages to fatal.txt. I have set up my property file as follows :

# Turn log4j debugging on
# log4j.debug = true



######################################
# Configure the log4j logging system
######################################

# Set the root output level and appenders
log4j.rootCategory=, FileAppender1, FileAppender2


log4j.category.CustRequestExtractor.class=debug FileAppender1

log4j.category.CustRequestExtractor.class=ERROR FileAppender2

log4j.appender.FileAppender1=org.apache.log4j.FileAppender
log4j.appender.FileAppender1.File=debug.txt
log4j.appender.FileAppender1.Threshold=debug,
log4j.appender.FileAppender1.layout=org.apache.log4j.PatternLayout
log4j.appender.FileAppender1.layout.ConversionPattern=%-5p [%t] %c-%m: %d{DATE}


log4j.appender.FileAppender2=org.apache.log4j.FileAppender
log4j.appender.FileAppender2.File=error.txt
log4j.appender.FileAppender2.Threshold=error
log4j.appender.FileAppender2.layout=org.apache.log4j.PatternLayout
log4j.appender.FileAppender2.layout.ConversionPattern=%-5p [%t] %c-%m: %d{DATE}


********************


I do get all errors logged to error.txt but my debug.txt contains debug + error messages.

Please help, I would really appreciate it.

thanks,
Bindiya

   <<Less

Re: Logging debug and error messages to separate files

Posted By:   michele_arpaia  
Posted On:   Thursday, January 30, 2003 02:47 AM

I had the same problem and I wrote up a .xml file properties. It looks like as following:






































And from the code:

URL url = Logger.class.getResource(file);
DOMConfigurator.configure(url)

enjoy loggin4j!

Re: Logging debug and error messages to separate files

Posted By:   Christopher_Schultz  
Posted On:   Tuesday, January 7, 2003 08:56 AM

I'm not sure if log4j allows you to specify a "range" of log levels to send to a particular appender. It only allows you to specify the "lowest" level allowed.



-chris
About | Sitemap | Contact