Hi,
I am trying to use this under Tomcat 5.0.27.
I have the following log4j.properties file under WEB-INF/conf/ # initialise root logger with level DEBUG and call it A1 log4j.rootLogger=DEBUG, A1 # set the appender to be FileAppender log4j.appender.A1=org.apache.log4j.FileAppender log4j.appender.A1.file=cw.log # set set that layout to be SimpleLayout log4j.appender.A1.layout=org.apache.log4j.SimpleLayout
I have the following in my web.xml <servlet> <servlet-name>Log4jInitServlet</servlet-name> <servlet-class>com.somepackage.Log4jInitServlet</servlet-class> <load-on-startup>1</load-on-startup> <init-param> <param-name>log4j-configuration</param-name> <param-value>conf/log4j.properties</param-value> </init-param> <init-param> <param-name>log4j-log-path</param-name> <param-value>WEB-INF/log</param-value> </init-param> </servlet>
I do the following in my Log4jInitServlet:
... String baseDir = getServletContext().getRealPath( "/" ); String logPath = config.getInitParameter(log4j-log-path); logPath = baseDir + logPath; File logPathDir = new File( logPath ); System.setProperty( "log.home", logPath ); PropertyConfigurator.configureAndWatch( confFile ); ...
When I start my tomcat engine, I do not get any exceptions but my log file does not get created? Am I missing something in my log4j.properties file while specifying log4j.appender.A1.file ? or something else? I do not get any exceptions in catalina.out.
I am trying to understand if this problem is due to my configuration of Tomcat or the configuration of my logger?
Mufaddal Khumri