tags:

views:

8

answers:

2

I am Eclipse and i am creating web project. Also i am using SLF4J for storing log into log file. I am putting log4j.properties file into the WEB-INF/classes folder

when i access the login page,the all associated logs and my debug statement log are get loaded into the log file. But i want the specific log (i.e project specific log) should be loaded into the log file instead of others log.

On the log file i can see

10/20/2010 10:16:24 - DEBUG - org.apache.commons.digester.Digester.sax   
.   
.   
.   
10/20/2010 10:16:24 - DEBUG - org.apache.commons.digester.Digester - [ObjectCreateRule]{resource-config/resource}New org.ajax4jsf.javascript.AjaxScript   
.   
.   
10/20/2010 10:16:24 - DEBUG - org.apache.commons.digester.Digester - [ObjectCreateRule]{resource-config/resource}New    
.   
.   
.   



10/20/2010 10:16:24 - DEBUG - org.apache.commons.digester.Digester.sax
.
.
.
10/20/2010 10:16:24 - DEBUG - org.apache.commons.digester.Digester - [ObjectCreateRule]{resource-config/resource}New org.ajax4jsf.javascript.AjaxScript
.
.
10/20/2010 10:16:24 - DEBUG - org.apache.commons.digester.Digester - [ObjectCreateRule]{resource-config/resource}New 
.
.
.

Can anyone help me to find out to store specific project related log into log file.??

Thanks

A: 

Have something like the following in your log4j.properties file:

log4j.logger.com.foo.logingubbins=DEBUG, loginfilelogger

log4j.appender.app=org.apache.log4j.RollingFileAppender
log4j.appender.loginfilelogger.File=c:/logs/login.log
log4j.appender.loginfilelogger.layout=org.apache.log4j.PatternLayout
log4j.appender.loginfilelogger.layout.ConversionPattern=%d [%t] %-5p [%c (%F:%L)] %n \t %m %n

That first line tells the logger to use a new logger for com.foo.logingubbins, which you direct to a separate file. You might want to add an additivity statement in there as well if you want it entirely separated.

The log4j manual can give you some useful examples, though I have to admit that the information on additivity is a little hazy.

Andy
A: 

Hi Andy,

  Thanks for reply. I added the folowing steps into log4j.properties file

log4j.logger.org.apache.commons.digester=ERROR log4j.category.se.bilprovningen.prippe=DEBUG,R

Now i am able to store project specific log into log file.

Thanks Arvind

arvind