Hi,
I am revamping a java application. We are planning to user Log4j but I am new to Log4j. My requirement is, I need to use the same log4j property file for 8 different module. I need to know how to configure different file names for different modules in the same log4j file. Thanks for your time
-
Setting Log4j Properties (5 messages)
- Posted by: Senthil Nathan
- Posted on: February 07 2005 05:30 EST
Threaded Messages (5)
- Re: Setting Log4j Properties by James Carman on February 07 2005 15:18 EST
- Re: Setting Log4j Properties by Matt A on March 03 2005 01:57 EST
-
2 Logger instances by Bruno Patini Furtado on May 29 2007 01:08 EDT
- Re: 2 Logger instances by J Dev on December 12 2008 05:52 EST
-
2 Logger instances by Bruno Patini Furtado on May 29 2007 01:08 EDT
- Re: Setting Log4j Properties by Matt A on March 03 2005 01:57 EST
- specify the appender by Fernando Garcia on February 17 2010 06:36 EST
-
Re: Setting Log4j Properties[ Go to top ]
- Posted by: James Carman
- Posted on: February 07 2005 15:18 EST
- in response to Senthil Nathan
You can split your loggers into different files. With the following example, all logging done to loggers in package "com.myco.a" and any subpackage thereof will be logged to module-a.log (likewise for module b). Now, as long as you separate your modules into packages like this, you're ok.
log4j.logger.com.myco.a=DEBUG, A
log4j.logger.com.myco.b=DEBUG, B
log4j.appender.A=org.apache.log4j.FileAppender
log4j.appender.A.File=a.log
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%d{[email protected]:mm:ss} %-5p (%13F:%L) %3x - %m%n
log4j.appender.B=org.apache.log4j.FileAppender
log4j.appender.B.File=b.log
log4j.appender.B.layout=org.apache.log4j.PatternLayout
log4j.appender.B.layout.ConversionPattern=%d{[email protected]:mm:ss} %-5p (%13F:%L) %3x - %m%n -
Re: Setting Log4j Properties[ Go to top ]
- Posted by: Matt A
- Posted on: March 03 2005 01:57 EST
- in response to James Carman
I do understand that, but what if I have to use two different loggers in lets say the same class. How do I get the specified logger a, or b?
Thank you very much for your help!
Regards,
Matt -
2 Logger instances[ Go to top ]
- Posted by: Bruno Patini Furtado
- Posted on: May 29 2007 13:08 EDT
- in response to Matt A
You just need to create 2 Logger instances using different names. -
Re: 2 Logger instances[ Go to top ]
- Posted by: J Dev
- Posted on: December 12 2008 05:52 EST
- in response to Bruno Patini Furtado
I have declared fileappender the same way, but some how file is not being generated. what may be the reason? jsptube.com -
specify the appender[ Go to top ]
- Posted by: Fernando Garcia
- Posted on: February 17 2010 06:36 EST
- in response to Senthil Nathan
When declare the "logger" variable, use this to specify de appender: private static Logger logger = Logger.getLogger("com.myco.b");