-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Logging each package in one file with log4j
PostPosted: Fri Jul 03, 2009 2:25 am 
Newbie

Joined: Wed Jul 01, 2009 10:56 am
Posts: 7
Hello, im trying to configure log4j and i have this properties for the project

log4j.properties


log4j.rootLogger = DEBUG, ManejadorLibro, org.hibernate, Ejemplo, Jaja


log4j.appender.org.hibernate = org.apache.log4j.RollingFileAppender
log4j.appender.org.hibernate.File = warning.txt
log4j.appender.org.hibernate.Threshold= WARN
log4j.appender.org.hibernate.layout = org.apache.log4j.PatternLayout
log4j.appender.org.hibernate.append=false
log4j.appender.org.hibernate.layout.ConversionPattern = [%p] [%d{yyyy-MM-dd @ HH:mm:ss}] [%t|%c{1}] %m%n


log4j.appender.ManejadorLibro = org.apache.log4j.RollingFileAppender
log4j.appender.ManejadorLibro.File = debug.txt
log4j.appender.ManejadorLibro.append=false
log4j.appender.ManejadorLibro.Threshold= DEBUG
log4j.appender.ManejadorLibro.layout = org.apache.log4j.PatternLayout
log4j.appender.ManejadorLibro.layout.ConversionPattern = [%p] [%d{yyyy-MM-dd @ HH:mm:ss}] [%t|%c{1}] %m%n


log4j.appender.Ejemplo = org.apache.log4j.RollingFileAppender
log4j.appender.Ejemplo.File = errores.txt
log4j.appender.Ejemplo.append=false
log4j.appender.Ejemplo.Threshold= ERROR
log4j.appender.Ejemplo.layout = org.apache.log4j.PatternLayout
log4j.appender.Ejemplo.layout.ConversionPattern = [%p] [%d{yyyy-MM-dd @ HH:mm:ss}] [%t|%c{1}] %m%n


i have the package prueba1 and prueba2.

But both log on the same files, is there someway to log them in different files?

thanks.


Top
 Profile  
 
 Post subject: Re: Logging each package in one file with log4j
PostPosted: Fri Jul 03, 2009 7:51 am 
Newbie

Joined: Sun Mar 01, 2009 11:11 pm
Posts: 9
yes it is possible to log in different file.


I am using XML style for log4j
and you can do it like


<logger name="org.company" additivity="false"><level value="INFO" /><appender-ref ref="company_APPENDER"/></logger>

Now All the logs of org.company can be redirected to company_APPENDER and since we have additivity="false" the log won't be sent to parent handler.

I would suggest you to switch from property file to xml. And you can check for more information in log4j site.


Top
 Profile  
 
 Post subject: Re: Logging each package in one file with log4j
PostPosted: Fri Jul 03, 2009 8:37 am 
Newbie

Joined: Wed Jul 01, 2009 10:56 am
Posts: 7
kannanmugundan wrote:
yes it is possible to log in different file.


I am using XML style for log4j
and you can do it like


<logger name="org.company" additivity="false"><level value="INFO" /><appender-ref ref="company_APPENDER"/></logger>

Now All the logs of org.company can be redirected to company_APPENDER and since we have additivity="false" the log won't be sent to parent handler.

I would suggest you to switch from property file to xml. And you can check for more information in log4j site.


ty ima try, i had alrdy switched like 3h ago :P, i could do it, making each class load a different properties, but it is a little dirty, one property per package -_-

oh and yeah i noticed its log4j :P, but is first time i use log4j and it "came" with hibernate (using old version) so asked here :X.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.