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>