You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by al...@pharma.novartis.com on 2004/07/08 16:02:46 UTC

Using Log4j in Struts 1.1

Hello All,
Can anybody send me the steps to config Log4j in struts1.1. Using 
commons-logging

Regards,
Alok Garg

Re: Using Log4j in Struts 1.1

Posted by Selim Hendrickson <se...@iyte.edu.tr>.
Hi,

You have to put the log4j.jar into the lib directory. Then you construct 
the log4j.properties file and put into the classes directory.
Here is a sample log4j.properties file:

log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.logger.org.apache.struts=DEBUG
log4j.logger.projectName=DEBUG
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{mm:ss} 
(%F:%M:%L)%n%m%n%n

import org.apache.commons.logging.Log and 
org.apache.commons.logging.LogFactory;

Then use: private static Log log = LogFactory.getLog(nameOfAction.class);

Anywhere you want to print a log message use:

log.trace("Your Message");

That should be all...

Take a look at the structure of the log4.properties file to find out 
about patterns and log levels. (DEBUG, WARN, etc.)
Pay attention that log.trace() is a certain log level and can be 
log.debug() as well. Take a look at the API.

Hope that helps,

Selim HENDRICKSON

IZTEK Consulting Services
Software Engineer
selimhendrickson [at] iyte.edu.tr
0232 750 6557

alok.garg@pharma.novartis.com wrote:

>Hello All,
>Can anybody send me the steps to config Log4j in struts1.1. Using 
>commons-logging
>
>Regards,
>Alok Garg
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org