Hello Allistair,

Thanks for your email.

My goal is Tomcat; to get started with Hibernate, I'm creating a
simple Person class, and plan to test database I/O outside Tomcat.

The log4j-1.2.8.jar is in the lib folder (in the directory
layout shown below), and I've sprinkled copies of Hibernate's
log4j.properties file in all conceivable folders (as marked).

By my reading of all Hibernate and Log4j documentation I can find,
this should work. But it doesn't, and it has me stumped. (In my
initial trials with Tomcat on this project, I dropped in a Log4j
properties file, and the jar, and it worked first time.)

Thanks again, and indeed for any more suggestions,

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





----- Original Message ----- 
From: "Allistair Crossley" <[EMAIL PROTECTED]>
To: "Log4J Users List" <[EMAIL PROTECTED]>
Sent: 28 July 2004 1:16 AM
Subject: RE: Getting Log4j Properties to Hibernate


What kind of environment are you running in? E.g Tomcat? Standalone? You
need to add log4j-1.2.8.jar into your LIB folder if this is a web
application. Tomcat would automatically pick that up. Then you can use the
log4j.properties file that comes with Hibernate and add that to your classes
folder (OR if you already have a log4j.proeperties, copy the entries in the
Hibernate version to your own). Hibernate logs sql to stdout anyway if you
set show_sql = true. It's rare you need the other stuff unless something
really goes wrong.

ADC


> -----Original Message-----
> From: William BC Crandall [mailto:[EMAIL PROTECTED]
> Sent: 28 July 2004 02:04
> To: Log4J Users List
> Subject: Getting Log4j Properties to Hibernate
>
>
>
> Hello,
>
> I hope someone here can give me a hint. I've been banging my head
> against a wall trying to get Hibernate tasks to see a log4j.properties
> or log4j.xml file for days. I'm using Ant (of course) for the build.
>
> I'm new to Hibernate, but have used Log4j before without difficulty.
> Hibernate's manual says you need only put log4j.jar and a properties
> file in the classpath, and everything will work. This has not been
> my experience.
>
> -----------------------------------------------------------------
>
>         The bit of Hibernate code I've focused on is hbm2java, which
>         generates Java source from hbm.xml templates. Following James
>         Elliott's nice intro book, the target is called <codegen>:
>
>   <target name="codegen" depends="prepare-configs"
>     description="Generate Java code from hbm.xml files.">
>
>     <taskdef name="hbm2java"
>       classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
>       classpathref="classpath.project"/>
>
>     <hbm2java output="${dir.src}">
>       <classpath>
>         <pathelement path="${classpath.project}"/>
>       </classpath>
>       <fileset dir="${dir.src}">
>         <include name="**/*.hbm.xml"/>
>       </fileset>
>     </hbm2java>
>   </target>
>
>
>         This *does* generate the file expected, but it complains:
>
> 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.
>
>
>
>  My attempts to get hbm2java to see a Log4j properties file:
>
>  1. Copied log4j.properties (from Hibernate's demo) throughout
>  the build directory ('*' marks dirs with properties file):
>
>
>    ap *               <--[build.xml is here]
>    |-build *
>    |  |-classes *
>    |     |-org *
>    |        |-apnp *
>    |           |-nrd *
>    |-lib *
>    |-src *
>    |  |-config *
>    |  |-org *
>    |     |-apnp *
>    |        |-nrd *
>
>
>
>  2. Altered classpath.project to include many locations:
>
>   <path id="classpath.project">
>     <pathelement location="${dir.src}"/>
>     <pathelement location="${dir.build}"/>
>     <pathelement location="${dir.build.classes}"/>
>     <pathelement location="${dir.build.classes}/org/apnp/nrd"/>
>
>     <fileset dir="${dir.src}/config">
>       <include name="*.properties"/>
>       <include name="*.dtd"/>
>       <include name="*.xml"/>
>     </fileset>
>     <fileset dir="${dir.lib}">
>       <include name="*.jar"/>
>       <include name="*.bat"/>
>     </fileset>
>     <fileset dir="${tomcat.lib}">
>       <include name="servlet-api.jar"/>
>     </fileset>
>   </path>
>
>
>
>  3. Made hbm2java use this classpath both as source for taskdef
>  and for running (as shown above):
>
>     <taskdef name="hbm2java"
>       classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
>       classpathref="classpath.project"/>
>
>     <hbm2java output="${dir.src}">
>       <classpath>
>         <pathelement path="${classpath.project}"/>
>       </classpath>
>       <fileset dir="${dir.src}">
>         <include name="**/*.hbm.xml"/>
>       </fileset>
>     </hbm2java>
>
>
>
>  4. Had codegen display 'classpath.project' between hbm2java
>  taskdef and running hbm2java:
>
>     <pathconvert targetos="windows" property="classpathProject"
>       refid="classpath.project"/>
>     <echo>classpathProject = ${classpathProject}  </echo>
>
>         Which shows (adding line breaks):
>
> [echo] classpathProject =
> C:\1-AbundantPlanet\ap\src;
> C:\1-AbundantPlanet\ap\build;
> C:\1-AbundantPlanet\ap\build\classes;
> C:\1-AbundantPlanet\ap\src\config\hibernate-configuration-2.0.dtd;
> C:\1-AbundantPlanet\ap\src\config\hibernate-mapping-2.0.dtd;
> C:\1-AbundantPlanet\ap\src\config\hibernate.cfg.xml;
> C:\1-AbundantPlanet\ap\src\config\hibernate.properties;
> C:\1-AbundantPlanet\ap\src\config\log4j.dtd;
> C:\1-AbundantPlanet\ap\src\config\log4j.properties;           <<<<
> C:\1-AbundantPlanet\ap\src\config\log4j.xml;                  <<<<
> C:\1-AbundantPlanet\ap\src\config\tomcat.properties;
> C:\1-AbundantPlanet\ap\src\config\tomcatTasks.properties;
> C:\1-AbundantPlanet\ap\lib\SchemaExport.bat;
> C:\1-AbundantPlanet\ap\lib\SchemaUpdate.bat;
> C:\1-AbundantPlanet\ap\lib\cglib-full-2.0.1.jar;
> C:\1-AbundantPlanet\ap\lib\class2hbm.bat;
> C:\1-AbundantPlanet\ap\lib\commons-collections-2.1.jar;
> C:\1-AbundantPlanet\ap\lib\commons-lang-1.0.1.jar;
> C:\1-AbundantPlanet\ap\lib\commons-logging-1.0.3.jar;
> C:\1-AbundantPlanet\ap\lib\ddl2hbm.bat;
> C:\1-AbundantPlanet\ap\lib\dom4j-1.4.jar;
> C:\1-AbundantPlanet\ap\lib\ehcache-0.7.jar;
> C:\1-AbundantPlanet\ap\lib\hbm2java.bat;
> C:\1-AbundantPlanet\ap\lib\hibernate-2.1.4.jar;
> C:\1-AbundantPlanet\ap\lib\hibernate-tools.jar;
> C:\1-AbundantPlanet\ap\lib\log4j-1.2.8.jar;                   <<<<
> C:\1-AbundantPlanet\ap\lib\mysql-connector-java-3.0.14.jar;
> C:\1-AbundantPlanet\ap\lib\odmg-3.0.jar;
> C:\Apache\Tomcat\Tomcat50\common\lib\servlet-api.jar
>
>
>
>  The log4j.properties file from Hibernate's distribution, is
>  simple ('warn' changed to 'debug'; comments and file appender
>  deleted):
>
> 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
>
> log4j.rootLogger=debug, stdout
> log4j.logger.net.sf.hibernate=debug
> log4j.logger.net.sf.hibernate.type=info
> log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug
>
>
>
>  The log4j.xml file, is also simple (file appender deleted):
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
>
> <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>
>
>   <!-- Root logger. Sends all debug-and-up messages to console. -->
>   <root>
>     <priority value="debug" />
>     <appender-ref ref="ConsoleAppender" />
>   </root>
>
> </log4j:configuration>
>
>
>
>  I'd be very grateful for any ideas on what else to test, or
>  how else to look at the problem.
>
>  Oh yes, Ant: 1.6.1. JVM: j2sdk-1.4.2
>
>  Thanks again,
>
>  William BC Crandall
>  bc.crandall [around] earthlink.net
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE>
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com";>www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


---------------------------------------------------------------------
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