You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian McGovern <bm...@imediainc.com> on 2005/02/22 16:22:33 UTC

RE: [RESOLVED] log4j.properties not found in tomcat

Unbelievable.  I'm still getting the error.  I have no idea how or why this went away temporarily but heres whats up.  Anyone who can help, its appreciated.  Some googling shows that others are having same error.  

Again, system variable log4j.configuration is set to log4j.properties which points RollingFileAppender to a file on my server.  
The log4j Appender file is LOGGING PROPERLY.  But any time i execute a servlet i get the followingn dump in stdout.log.  NO idea why.


log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:297)
        at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:315)
        at com.imediainc.nycballet.nycbbuilder.dataaccess.DBConnection.getConnection(Unknown Source)
        at com.imediainc.nycballet.nycbbuilder.dataaccess.NYCBData.getAllReps(Unknown Source)
        at com.imediainc.nycballet.nycbbuilder.control.RepsMainController.execute(Unknown Source)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
        at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
        at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
        at org.apache.jsp.reps.index_jsp._jspService(index_jsp.java:43)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
        at java.lang.Thread.run(Unknown Source)
log4j:ERROR Ignoring configuration file [log4j.properties].
AbandonedObjectPool is used (org.apache.commons.dbcp.AbandonedObjectPool@1195c2b)
   LogAbandoned: true
   RemoveAbandoned: true
   RemoveAbandonedTimeout: 60


-----Original Message-----
From: Brian McGovern [mailto:bmcgovern@imediainc.com]
Sent: Tuesday, February 22, 2005 8:24 AM
To: Tomcat Users List
Subject: RE:[RESOLVED] log4j.properties not found in tomcat


Thanks for the repliess.  My issue was that I needed to set a system wide environment variable called log4j.configuration and set its value to "log4j.properties", the name of my config file for log4j.  This was in the log4j documentation but I guess i skimmed over that part.  Log4j is a application completely separate from web container, hence the need for a system wide var.  Definately liking log4j more and more.  

My file was located in my /webapps/myappuri/WEB-INF/classes/  So the answer turns out that log4j looks for a system env var log4j.configuration and looks in your webapps class path for it.  

Additionally I set up tomcat to use my log4j file as well by makin a file called commons-logging.properties in /webapps/myappuri/WEB-INF/classes/ whos only line was:

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

Note that commons-logging.jar needs to be in your /webapps/myappuri/WEB-INF/lib/ dir for this to work.

Thanks
-B



-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]
Sent: Tuesday, February 22, 2005 12:30 AM
To: Tomcat Users List
Subject: Re: log4j.properties not found in tomcat



You have to understand that any relative path is going to be resolved 
relative to the location where the JVM started.  If you started Tomcat via 
the service rather than the batch files, then the VM would be run, by 
default, from C:\winnt\System32.  So, when you supplied 
"-Dlog4j.configuration=log4j.properties", you got exactly what should be 
expected if log4j.properties were located in c:\winnt\System32.  Same goes 
for relatively defined paths to log files defined for FileAppenders in 
log4j.properties.

BTW, can you post your error?   FileNotFoundExceptions aren't thrown when 
Log4j can't find its config file.  You'd get a simple error saying as 
much.  The FileNotFoundExceptions are usually thrown when you specify a 
file for a FileAppender in a directory that doesn't exist.  Log4j makes no 
attempt to create directories if they don't exist already.  This is the 
correct and safe thing to do.  It is your responsibility to make sure the 
directory exists before Log4j attempts to use it.


Jake

At 11:09 PM 2/21/2005 -0500, you wrote:
 >Where do you put  log4j.properties currently?
 >-Michael Greer
 >
 >On Feb 21, 2005, at 5:02 PM, Brian McGovern wrote:
 >
 >> I have a wierd problem.  Tomcat on W2k barks FileNotFound Exceptions
 >> for the log4j.properties file when i execute a servlet that
 >> instantiates log4j.  Strangely enough the actual file that i create
 >> and log to with log4j.properties file logs out just fine even though
 >> stdout.log said that it couldn't find my log4j.properties file.
 >>
 >> Only time i don't get an error is when i put log4j.properites in my
 >> winnt/system32 directory.  But this doesnt make sense to me.  I supply
 >> -Dlog4j.configuration=log4j.properties to Java at startup and still
 >> get the same error.  I also tried the FULL path to my log4j.properties
 >> in the -D option.
 >>
 >> Instantiated like this across my app.
 >>
 >> private static final Logger zLogger =
 >> Logger.getLogger(MyClassName.class);
 >>
 >> Can anyone tell me where I went wrong.
 >>
 >> thanks
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
 >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
 >
 >  


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


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


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