Originally posted by N Nanda:
Hi all,
I am using struts 1.1 with Tomcat5.0.16 for my project. I have configured tomcat's server.xml file and set my own context (its in D:\myweb). Not I want to have my own log file in D:\myweb\WEB-INF\logs folder. can anyone help me how i can do it. Its an urgency.
Thanks in advance.
N Nanda
download log4j, place in lib directory of webapps/lib
configure your log4j.properties like below and put it under web-inf/classes
# Global logging configuration
log4j.rootLogger=WARN, fileout, stdout
# replace com.lecare with your package names for which you want logging support
log4j.logger.com.lecare=DEBUG
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss} [%t] - %m%n
# Rolling log file output...
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=c:/actions.log
#log4j.appender.fileout.File=c:/webserve/log/actions.log
log4j.appender.fileout.MaxFileSize=1024KB
log4j.appender.fileout.MaxBackupIndex=5
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%5p %d{dd MMM HH:mm:ss} [%t] (%F:%L) - %m%n
import logging classes:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
declare logger for the class
private Log logger = LogFactory.getLog(this.getClass());
for more information on using log4j read log4j documentation.