I had the same problem and was only able to solve it by forceably loading the log4j
configuration file. I put the following in the servlet's init() method:
// get log4j property file.
java.net.URL log4jProps =
ActionServlet.class.getClassLoader().getResource("log4j.properties");
System.out.println("System.out.println - Log4j URL: " + log4jProps);
// configure log4j
PropertyConfigurator.configure(log4jProps);
Mike
-----Original Message-----
From: rablists [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 7:51 AM
To: [EMAIL PROTECTED]
Subject: common-logging, Struts, Log4j
Hi. I have problem in using the common-logging with struts and
Log4j. I am basically lost. I have short questions, I appreciate if
anyone can help me little bit. these are the questions with examples:
The file outputfile.log that I specify in
log4j.appender.LOGFILE.File=outputfile.log where it is located?
where I find it? is it physical file?
I dont know why my configuration is not working, although I put the
following files in the classpath WEB-INF/classes/org/myclasses/:
commons-logging.properties:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JL
ogger
log4j.properties:
log4j.rootLogger=DEBUG, rolling
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%
n
log4j.appender.rolling=org.apache.log4j.RollingFileAppender
log4j.appender.rolling.File=outputfile.log
log4j.appender.rolling.MaxFileSize=100KB
log4j.appender.rolling.MaxBackupIndex=1
log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.rolling.layout.ConversionPattern=%d{ABSOLUTE} - %p %
c - %m%n
What else should I specify, or configure to make it to work? I have
log4j-1.2.4.jar in my WEB-INF/lib/
Should I set any system propreties? or web.xml? or struts-config?
In my classes I am doing that:
protected static final org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(this.class);
if (log.isDebugEnabled())
log.debug("getMessage(" + locale + "," + key + ")");
(How can I enable/disable the Debug or Trace?)
Thank you in advance. I am really stuck and I couldnt make it to
work. I am using tomcat 4.18
Rabih
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]