komlaaa
asked on
log4j
In my webap involving tomcat, strut, hibernate. Every is working fine. I have also setup log4j but unable to print debug output to the console. Please see snippets:
public class CreateCustomerAction extends AbstractAction {
....................
private static Log log = LogFactory.getLog(CreateCustomerAction.class );
.....................
if ( log.isDebugEnabled() ){
log.debug("just read firstName:"+ fn
+", lastName: " + ln
+", emailAddress: "+ ad
+", custumerID: " + custId);
}
log4j.properties:
=================
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{mm:ss}
(%F:%M:%L)%n%m%n%n
log4j.logger.org.apache.struts=DEBUG
org.hibernate.SQL=DEBUG
org.hibernate.type=DEBUG
org.hibernate.tool.hbm2ddl=DEBUG
org.hibernate.pretty=DEBUG
org.hibernate.cache=DEBUG
org.hibernate.transaction=DEBUG
org.hibernate.jdbc=DEBUG
org.hibernate.hql.ast.AST=DEBUG
org.hibernate.secure=DEBUG
org.hibernate=DEBUG
you need to specify debug level for the package that class belongs to
you don't need
" if ( log.isDebugEnabled() ){"
and perhaps you could try log4j.rootLogger=DEBUG
are you sure the properties file is on the classpath ? try a system.out after your if ( log.isDebugEnabled() )
br,
themuppeteer
http://users.telenet.be/free_quiz
" if ( log.isDebugEnabled() ){"
and perhaps you could try log4j.rootLogger=DEBUG
are you sure the properties file is on the classpath ? try a system.out after your if ( log.isDebugEnabled() )
br,
themuppeteer
http://users.telenet.be/free_quiz
ASKER
>>
you need to specify debug level for the package that class belongs to
How?
>>
and perhaps you could try log4j.rootLogger=DEBUG
i did and when it start tomcat i end up in an infinite loop on my c: prompt tomcat console
Thanks
you need to specify debug level for the package that class belongs to
How?
>>
and perhaps you could try log4j.rootLogger=DEBUG
i did and when it start tomcat i end up in an infinite loop on my c: prompt tomcat console
Thanks
ASKER
i use this is example(http://www.theserverside.com/discussions/thread.tss?thread_id=31659)
to create the property file below but i am still not getting any log output,... can someone help?
to create the property file below but i am still not getting any log output,... can someone help?
package actions;
...........
public class CreateCustomerAction extends AbstractAction {
private static Log log = LogFactory.getLog(CreateCustomerAction.class);
.............
if (log.isDebugEnabled()){
log.debug("just read firstName:"+ fn
+", lastName: " + ln
+", emailAddress: "+ ad
+", custumerID: " + custId);
}
the current log4j.properties file
=================================
log4j.logger.actions=DEBUG,CreateCustomerAction
llog4j.appender.CreateCustomerAction=org.apache.log4j.FileAppender
log4j.appender.CreateCustomerAction.File=createCustomerAction.log
log4j.appender.CreateCustomerAction.layout=org.apache.log4j.PatternLayout
log4j.appender.CreateCustomerAction.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n
log4j.logger.org.apache.struts=DEBUG
org.hibernate.SQL=DEBUG
org.hibernate.type=DEBUG
org.hibernate.tool.hbm2ddl=DEBUG
org.hibernate.pretty=DEBUG
org.hibernate.cache=DEBUG
org.hibernate.transaction=DEBUG
org.hibernate.jdbc=DEBUG
org.hibernate.hql.ast.AST=DEBUG
org.hibernate.secure=DEBUG
org.hibernate=DEBUG
by adding this to your original properties file
log4j.logger.action=DEBUG, stdout
log4j.logger.action=DEBUG,
ASKER
i added "log4j.logger.actions=DEBU G, stdout" but still can't haave an output of what i added in my class.
The output generated is shown on screen shot added
Please see below the current log4J.properties.
The output generated is shown on screen shot added
Please see below the current log4J.properties.
log4j.rootLogger=WARN, stdout
log4j.logger.actions=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{mm:ss}
(%F:%M:%L)%n%m%n%n
log4j.logger.org.apache.struts=DEBUG
org.hibernate.SQL=DEBUG
org.hibernate.type=DEBUG
org.hibernate.tool.hbm2ddl=DEBUG
org.hibernate.pretty=DEBUG
org.hibernate.cache=DEBUG
org.hibernate.transaction=DEBUG
org.hibernate.jdbc=DEBUG
org.hibernate.hql.ast.AST=DEBUG
org.hibernate.secure=DEBUG
org.hibernate=DEBUG
log4j.JPG
is WARN logging showing up from that class?
ASKER
>> is WARN logging showing up from that class?
After i inserted these lines in that class, i have the screen shot below: note some WARN printed there. So, yes WARN is showing there.
if (logger.isWarnEnabled()){
logger.warn("just read firstName:"+ fn
+", lastName: " + ln
+", emailAddress: "+ ad
+", custumerID: " + custId);
}
log4j.JPG
After i inserted these lines in that class, i have the screen shot below: note some WARN printed there. So, yes WARN is showing there.
if (logger.isWarnEnabled()){
logger.warn("just read firstName:"+ fn
+", lastName: " + ln
+", emailAddress: "+ ad
+", custumerID: " + custId);
}
log4j.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.