If Log4j.jar is in a shared location, you can't expect it to find log4j.properties in WEB-INF/classes. When Log4j auto-configures itself from this location, it will only find log4j config files in that same classloader or higher. For instance, $catalina.home/shared/classes or somewhere in Tomcat's startup classpath.

You will save yourself trouble by putting log4j.jar in WEB-INF/lib, especially since hibernate is in WEB-INF/lib. If you have other shared libraries that depend on Log4j, it's ok to have Log4j in a shared location *and* in WEB-INF/lib. You will have a separate configuration for the shared stuff than the webapp stuff because each webapp will have it's own Log4j instance while the shared stuff will use another. You can also have a single shared Log4j instance and use separate logger repositories (via a repository selector) to allow for separate config per/app and for the shared libraries. The latter is more complex and may not be what you want to try first. I really recommend putting log4j.jar in WEB-INF/lib. That will solve your issue quickly, though, if you are going to use log4j.properties, you still need to make sure you don't have a log4j.xml anywhere on the classpath because it will be used in preference to your own log4j.properties.

Note also that, if you are going to put log4j.jar in a shared location, it should be in common/lib, not shared/lib. This is so that libraries in common/lib can see logj4.jar as well as those in shared/lib. Put a Log4j configuration file in common/classes. This will configure the shared instance of Log4j. Then for each app put log4j.jar in WEB-INF/lb and the app's config file in WEB-INF/classes (preferably log4j.xml).


Jake

At 07:04 PM 3/2/2007, you wrote:
>Thank you for the recommendation on log4j.xml, I will keep it in mind.
>
>I'm new to the project team, but will see if I can convince them to
>change to .xml insead of .properties. I'll probably change it myself
>after becoming familiar with Log4J.
>
>I looked in the Unix system, and there were a few Log4J property files
>on different projects, since the log4j.jar file is located under
>/tomcat/ .... /shared/ folder it's probably reading
>the property files from other projects and/or tomcat folder , I have a
>few more tasks to complete on the project and will investigate the
>file conflicts after a few days.
>
>-Regards
>Rashmi
>
>----- Original Message ----
>From: James Stauffer <[EMAIL PROTECTED]>
>To: Log4J Users List <[email protected]>
>Sent: Friday, March 2, 2007 1:43:08 PM
>Subject: Re: Newbie trying to change Standard Output log to File log
>
>
>If you change to use a log4j.xml the will be used in preference to any
>log4j.properties.
>
>On 3/2/07, Rashmi Rubdi <[EMAIL PROTECTED]> wrote:
>> Hi Jacob,
>>
>> Thanks for your reply.
>>
>> - hibernate3.jar - does not contain log4j.properties or log4j.xml file
>>
>> - the modified log4j.properties file is first placed under the Java
>source folder, and upon
>>   building with Ant, it gets moved to the /WEB-INF/classes/ folder ,
>immediately under /classes , I looked at the log4j.properties under
>classes and it is the modified version (supposed to log to a file and
>not std out)
>>
>> - C:\dev\tomcat\apache-tomcat-5.5.20\shared\lib\log4j.jar , and
>similar corresponding location in Unix as well. (this is where the
>project team placed it originally)
>>
>> - Hibernate library is under /WEB-INF/lib/ folder of the project
>>
>> - log4j.jar is in the shared folder, hibernate3.jar is in the
>project folder and log4j.properties is in the project's classes folder.
>>
>> I was told that there is another log4j.properties on the Unix
>machine, perhaps that properties file is conflicting with the
>log4j.properties I have in the classes folder.
>>
>> At least it is good to know that the log4j.properties has been
>configured properly, now I'll check to see if there are any
>conflicting property files.
>>
>> Thanks a lot for the suggestions, I will take a look at this.
>>
>> -Regards
>> Rashmi
>>
>>
>> ----- Original Message ----
>> From: Jacob Kjome <[EMAIL PROTECTED]>
>> To: Log4J Users List <[email protected]>
>> Sent: Friday, March 2, 2007 12:32:48 PM
>> Subject: Re: Newbie trying to change Standard Output log to File log
>>
>>
>> Does HIbernate package log4j.properties in their library?  Where do
>> you put your modified log4j.properties?  Log4j auto-configures itself
>> in a static initializer and looks first for log4j.xml and then
>> log4j.properties (if the former isn't found) in the default
>> package.   Are you sure your modified version is being found instead
>> of the unmodified version (or even some other Log4j config file in
>> the classpath)?  Where do you put log4j.jar?  Where do you put the
>> hibernate library?  Are hibernate.jar and log4j.jar in a shared
>> classloader or in WEB-INF/lib?  Is your config file in
>> WEB-INF/classes or a shared location?
>>
>> These are all things to look into.  I would hasten to bet that your
>> modified config file is not being utilized.  By answering the
>> questions above, and thinking about how classloaders work (taking
>> into account Tomcat's child-first webapp classloader), you should be
>> able to solve the issue.
>>
>> Jake
>>
>> At 11:08 AM 3/2/2007, you wrote:
>>  >Hello Everyone,
>>  >
>>  >I'm new to Log4J. I think we're using Log4J version 1.2.8.
>>  >On Tomcat 5.5
>>  >
>>  >I am using the basic Log4J properties file that comes with Hibernate
>>  >Version 3.3.2 distribution:
>>  >
>>  >By default the properties file is configured to send the output to
>> the console
>>  >
>>  >Here's what came with Hibernate:
>>  >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>  >
>>  >### direct log messages to stdout ###
>>  >log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>>  >log4j.appender.stdout.Target=System.out
>>  >log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>>  >log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
>> %c{1}:%L - %m%n
>>  >
>>  >### direct messages to file hibernate.log ###
>>  >#log4j.appender.file=org.apache.log4j.FileAppender
>>  >#log4j.appender.file.File=hibernate.log
>>  >#log4j.appender.file.layout=org.apache.log4j.PatternLayout
>>  >#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p
>> %c{1}:%L - %m%n
>>  >
>> >### set log levels - for more verbose logging change 'info' to 'debug' ###
>>  >
>>  >log4j.rootLogger=warn, stdout
>>  >
>>  >#log4j.logger.org.hibernate=info
>>  >log4j.logger.org.hibernate=debug
>>  >
>>  >### log HQL query parser activity
>>  >#log4j.logger.org.hibernate.hql.ast.AST=debug
>>  >
>>  >### log just the SQL
>>  >#log4j.logger.org.hibernate.SQL=debug
>>  >
>>  >### log JDBC bind parameters ###
>>  >log4j.logger.org.hibernate.type=info
>>  >#log4j.logger.org.hibernate.type=debug
>>  >
>>  >### log schema export/update ###
>>  >log4j.logger.org.hibernate.tool.hbm2ddl=debug
>>  >
>>  >
>>  >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>  >
>>  >Then, I made changes to the above properties file, to make the output
>>  >be logged in a file instead
>>  >of standard output.
>>  >
>>  >as follows upon searching on Google (but the output of the log still
>>  >goes to standard output instead of a file)
>>  >
>>  >### direct log messages to stdout ###
>>  >#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>>  >#log4j.appender.stdout.Target=System.out
>>  >#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>>  >#log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
>>  >%c{1}:%L - %m%n
>>  >
>>  >### direct messages to file hibernate.log ###
>>  >log4j.appender.file=org.apache.log4j.FileAppender
>>  >log4j.appender.file.File=hibernate.log
>>  >log4j.appender.file.layout=org.apache.log4j.PatternLayout
>>  >log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p
>%c{1}:%L - %m%n
>>  >
>> >### set log levels - for more verbose logging change 'info' to 'debug' ###
>>  >
>>  >#log4j.rootLogger=warn, stdout
>>  >log4j.rootLogger=warn, file
>>  >
>>  >#log4j.logger.org.hibernate=info
>>  >log4j.logger.org.hibernate=info
>>  >
>>  >### log HQL query parser activity
>>  >#log4j.logger.org.hibernate.hql.ast.AST=debug
>>  >
>>  >### log just the SQL
>>  >#log4j.logger.org.hibernate.SQL=debug
>>  >
>>  >### log JDBC bind parameters ###
>>  >#log4j.logger.org.hibernate.type=info
>>  >log4j.logger.org.hibernate.type=debug
>>  >
>>  >### log schema export/update ###
>>  >log4j.logger.org.hibernate.tool.hbm2ddl=debug
>>  >
>>  >I looked at the example here:
>>  >http://ideoplex.com/id/386/controlling-hibernate-output-with-log4j
>> to make the
>>  >above change, but I'm confused as to why the log is still being
>>  >directed to the console rather than hibernate.log file.
>>  >
>>  >I plan to read the Log4J manual and understand the various notations
>>  >used in the properties file.
>>  >
>>  >Any help is appreciated.
>>  >
>>  >-Regards
>>  >Rashmi
>>  >
>>  >
>>  >
>>  >
>>  >
>>  >______________________________________________________________________
>>  >______________
>>  >Never miss an email again!
>>  >Yahoo! Toolbar alerts you the instant new Mail arrives.
>>  >http://tools.search.yahoo.com/toolbar/features/mail/
>>  >
>>  >---------------------------------------------------------------------
>>  >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]
>>
>>
>>
>>
>>
>>
>>
>>
>______________________________________________________________________
>______________
>> Expecting? Get great news right away with email Auto-Check.
>> Try the Yahoo! Mail Beta.
>> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
>--
>James Stauffer        http://www.geocities.com/stauffer_james/
>Are you good? Take the test at http://www.livingwaters.com/good/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>______________________________________________________________________
>______________
>Be a PS3 game guru.
>Get your game face on with the latest PS3 news and previews at Yahoo! Games.
>http://videogames.yahoo.com/platform?platform=120121
>
>---------------------------------------------------------------------
>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