Announcement Announcement Module
Collapse
No announcement yet.
logging configuration question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • logging configuration question

    Hi,

    I am trying to setup logging but can't figure out where to put the log4j.properties file.

    I am using Eclipse and right now my little project has a src folder for sources and a bin folder for built files. Under src I created my package hierarchy ending with test. In that test package I have a JUnit TestCase to test my DAO with iBatis. Evrything works fine except logging.

    My log4j.properties file is just under src. In that folder, there is another jdbc.properties file that is loaded by iBatis maps, so I know it should be accessible. However, it doesn't seem it is and I haven't found a way to test it.

    Here is my log4j.properties:

    Code:
    log4j.rootLogger=WARN,stdout
    log4j.logger.org.springframework=ERROR,stdout
    
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout-org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
    What am I missing?

    TIA

    Pascal

  • #2
    Do you have Log4J on the project's classpath ("build path" under the project's properties)? Do you have the commons-logging.jar there too (Spring uses this)? Finally, your code creating and using a Log4J Logger correctly? I think those are the most likely causes, but its hard to say without more data. Using Eclipse 3.0 and 3.1m4 I have been able to use a similar setup to the one you describe with correct results.

    Comment


    • #3
      One thing I've done to debug this kind of problem is to simply output which logger is really being used. Or use a debugger. At one time, I thoght I was using log4j, but was using another. (output format should have told me, duh).
      Code:
      Log log = LogFactory.getLog(this.getClass());
      syserr(log.getClass());

      Comment


      • #4
        Thank you both. I was missing a common-logging.properties file. Adding this line to it fix all my Logging problems.

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

        Comment

        Working...
        X