-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: log4j.xml and hbm2java
PostPosted: Sun Jul 18, 2004 12:46 am 
Newbie

Joined: Thu Jul 15, 2004 6:33 pm
Posts: 9
Location: Mill Valley, CA
Hello Fellow Hibernators,

I'm using Log4j with a log4j.xml configuration file in my web
application. This works fine.

I'd like to use that configuration file (below) with Hibernate,
but I can't get past this familiar error:

Code:
codegen:
[hbm2java] Processing 1 files.
[hbm2java] Building hibernate objects
[hbm2java] log4j:WARN No appenders could be found for
               logger (net.sf.hibernate.util.DTDEntityResolver).
[hbm2java] log4j:WARN Please initialize the log4j system properly.



Files *are* created by hbm2java as I'd like--almost. (The "almost" is
the driving force behind my desire to get logging working.)

I've created a commons-logging.properties file (below) and tried
copying these two files to various locations in my development tree,
but to no effect (trial locations marked with '*'):

Code:
   ap
   |-build
   |  |-classes
   |     |-org *
   |        |-apnp
   |           |-nrd *
   |-lib *
   |-src
   |  |-org *
   |     |-apnp
   |        |-nrd *



Many thanks for any suggestions.

William BC Crandall
bc.crandall [around] earthlink.net


Code:

----------------------------------------------------------------------
Jars:

hibernate2.1.4.jar
log4j-1.2.8.jar           
commons-logging.jar: 1.0.3

----------------------------------------------------------------------
commons-logging.properties:

# Use Log4j  (tried both)
#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
org.apache.commons.logging.log=org.apache.commons.logging.impl.Log4JCategoryLog

# Configuration file of the log
log4j.configuration=log4j.xml

----------------------------------------------------------------------
log4j.xml:

<log4j:configuration debug="true"
  xmlns:log4j="http://jakarta.apache.org/log4j/">

  <!-- System.out appender. -->
  <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
   value="%d{HH:mm:ss} [%5.5t] %-5p [%-20.30c{1}] %x - %m\n"/>
    </layout>      
  </appender>

  <!-- File appender. -->
  <appender name="FileAppender" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="C:/1-AbundantPlanet/ap/log/log4j.log"/>
    <param name="Append" value="true"/>
    <param name="ImmediateFlush" value="true"/>
    <param name="MaxFileSize" value="500KB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
   value="%d{HH:mm:ss} [%5.5t] %-5p [%-20.30c{1}] %x - %m\n"/>
    </layout>
  </appender>

  <!-- Root logger. Sends all debug-and-up messages to console.
  All loggers inherit their settings from the root logger. -->
  <root>
    <priority value="debug" />
    <appender-ref ref="ConsoleAppender" />
  </root>

  <!-- Logger sending messages to a file. -->
  <logger name="org.apnp.nrd">
    <priority value="debug" />
    <appender-ref ref="FileAppender" />
  </logger>


</log4j:configuration>


Top
 Profile  
 
 Post subject: Re: log4j.xml and hbm2java
PostPosted: Sun Jul 18, 2004 11:12 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
Is it logging at all, and you get the warning, or are you not getting any logging output? I get this warning when I dynamically configure the logger, but something might have been logged before the logger is setup. In which case I ignore the warning. But if you arent getting any logs written, then it is a problem. Fix this (probably or warning) by making sure the default logger is configured in the log4j properties file and on your classpath. This webpage walks you through this:

http://www.gloegl.de/8.html (CTRL-f appender)

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 10:31 pm 
Newbie

Joined: Thu Jul 15, 2004 6:33 pm
Posts: 9
Location: Mill Valley, CA
Thanks Chris,

After this and that, looked in last place (as usual)
and found a bad log4j.jar in my Ant folder. It was
knocking out the correct jar in my lib folder.
Obscure, but solved. Thanks again for your pointer.

-BC


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.