You've got to have something wacky set up on your systems.  File IO is not used
when Log4j picks the config file up from the classpath.  This leads me to
believe that log4j.configuration is set somewhere else upon each invocation of
Tomcat.  You probably just set it earlier in the launching of Tomcat overriding
the one pointing to a log4j.properties file that doesn't exist.

I and others have use the auto-configuration paradigm with log4j.jar in
WEB-INF/lib and the config file in WEB-INF/classes for ages and haven't ever
seen the issue you are seeing.  That tells me that the problem is in your
setup, not in Log4j.  I suggest you set up a clean-room environment and try
this out.  I bet it works.  Then try to figure out what's wrong in your other
environments.


Jake

Quoting Brian McGovern <[EMAIL PROTECTED]>:

> Then theres something else going on.  I didnt set log4j.configuration  when i
> started, i just had my log4j.jar in my WEB-INF/lib/ and my log4j.properties
> in my /WEB-INF/classes/  However i still got that file not found exception.
>
> I think its gotta either the way im calling it or the properties file itself.
>  I say this because ive now tried on 2 machines 2 OS's and same thing
> happened.  It MAKES me define a system wide log4j.configuration.  This cannot
> be right.  Makes the whole use of log4j pointless and non portable.
>
> At any rate, ive got that wacky system-wide var defined and it supresses
> errors, just doesnt work the way i want.
>
>
> Calling like this:
> private static final Logger zLogger =
> Logger.getLogger(RepsMainController.class);
> zLogger.debug("something logged here");
>
> log4j.properties like this:
> log4j.rootLogger=DEBUG, nycbbuilderlog
> log4j.appender.nycbbuilderlog=org.apache.log4j.RollingFileAppender
> log4j.appender.nycbbuilderlog.File=${catalina.home}/logs/catalina.out
> log4j.appender.nycbbuilderlog.MaxFileSize=10000KB
> log4j.appender.nycbbuilderlog.MaxBackupIndex=2
> log4j.appender.nycbbuilderlog.layout=org.apache.log4j.PatternLayout
> log4j.appender.nycbbuilderlog.layout.ConversionPattern=%5p
> [EMAIL PROTECTED]:mm:ss,SSS}] - %m%n
>
>
> -----Original Message-----
> From: Jacob Kjome [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 22, 2005 3:01 PM
> To: Tomcat Users List
> Subject: RE:[RESOLVED] log4j.properties not found in tomcat
>
>
> Quoting Brian McGovern <[EMAIL PROTECTED]>:
>
> > 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.
> >
>
> No, I'm pretty sure this is not the case.  log4j.configuration does not need
> to
> be specified.  If it is, I believe it is assumed to be a file location.  If
> relatively defined, it is resolved relative to the location that the JVM
> started.  If not defined, Log4j looks in the classloader.  Actually, I
> haven't
> checked, but it may fall back to the classloader if it can't find the log4j
> config file in the location specified by the system property.  You'll have to
> verify that.
>
> > 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.
>
>
> If you want Log4j to be a system-wide service, you should really add
> log4j.jar
> and commons-logging.jar to CATALINA_HOME/common/lib and add log4j.properties
> to
> CATALINA_HOME/common/classes.  There is no need for the
> commons-logging.properties file in that case.  And it is kludgy to provide
> server-level properties inside a webapp.  BTW, do you have log4j.jar in your
> WEB-INF/lib?  If so, you are simply logging for your webapp alone, not
> system-wide.
>
> Jake
>
> >
> > Thanks
> > -B
> >
> >
> >
> > -----Original Message-----
> > From: Jacob Kjome [mailto:[EMAIL PROTECTED]
> > 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: [EMAIL PROTECTED]
> >  >For additional commands, e-mail: [EMAIL PROTECTED]
> >  >
> >  >
> >
> >
> > ---------------------------------------------------------------------
> > 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]
> >
>
>
>
>
> ---------------------------------------------------------------------
> 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]
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to