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.  [ 5 posts ] 
Author Message
 Post subject: Log4J problems
PostPosted: Fri Oct 13, 2006 10:52 am 
Newbie

Joined: Fri Oct 13, 2006 10:43 am
Posts: 3
Ellow,

I'm running a java application on Websphere 6. I'm also using hibernate, spring and log4j. When hibernate gives problems, Websphere is logging these problemes in HIS logfile (SystemOut.log). I want to specify my own logfile but this seems to go wrong. Also when I do an insert, update or delete Websphere is logging this in his logfiles. My current log4j configuration is

log4j.rootLogger=DEBUG, unexpected
log4j.logger.org.hibernate=DEBUG, hibernate
log4j.additivity.org.hibernate=false

log4j.appender.hibernate.Encoding=UTF-8
log4j.appender.hibernate=org.apache.log4j.RollingFileAppender
log4j.appender.hibernate.File=Z:/logs/single_engine/hibernate.log
log4j.appender.hibernate.MaxFileSize=10000KB
log4j.appender.hibernate.MaxBackupIndex=10
log4j.appender.hibernate.layout=org.apache.log4j.PatternLayout
log4j.appender.hibernate.layout.ConversionPattern=%d %5p [%t] %c{1} - %L %m%n


A part of my Spring configuration is:
<prop key="hibernate.show_sql">${something.hibernate.show_sql}</prop> (for logging the sql results)

I hope somebody can help me. Thank in advance.

Kind regards,

Kimme








Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject: Log4j and Hibernate
PostPosted: Fri Oct 13, 2006 11:04 am 
Newbie

Joined: Fri Aug 04, 2006 3:01 pm
Posts: 13
First thing first, you should use an XML based configuration file. It's much more easy to maintain, to configure and to understand.

That said, here's an example of a working Log4j XML config which outputs the Hibernate output to the logs.

As you can guess, the logger name (org.hibernate) is the base package of hibernate and redirects it's output to the specified appenders. You can create more appenders as needed.

Hope this helps.

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4j:configuration PUBLIC
   "-//Apache Software Foundation//DTD Log4j//EN"
   "http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/log4j.dtd">

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

   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%-5p - %d %c [%t]%n%m%n" />
      </layout>
   </appender>

   <appender name="ERRORS" class="org.apache.log4j.DailyRollingFileAppender">
      <param name="File" value="${catalina.home}/logs/ERRORS.log" />
      <param name="DatePattern" value="'.'dd-MM-yyyy" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%-5p - %d %c [%t]%n%m%n" />
      </layout>
      <filter class="org.apache.log4j.varia.LevelRangeFilter">
         <param name="LevelMin" value="ERROR" />
         <param name="LevelMax" value="FATAL" />
      </filter>
   </appender>

   
   

   <appender name="SPRING" class="org.apache.log4j.DailyRollingFileAppender">
      <param name="File" value="${catalina.home}/logs/ICOPE-SPRING.log" />
      <param name="DatePattern" value="'.'dd-MM-yyyy" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%-5p - %d %c [%t]%n%m%n" />
      </layout>
   </appender>

   <appender name="EMAIL" class="org.apache.log4j.net.SMTPAppender">
      <param name="BufferSize" value="512" />
      <param name="SMTPHost" value="XXX.XXX.XXX.XXX" />
      <param name="From" value="x@x.com" />
      <param name="To" value="x@x.com" />
      <param name="Subject" value="Icope" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="[%d{ISO8601}]%n%n%-5p%n%n%c%n%n%m%n%n" />
      </layout>
      <filter class="org.apache.log4j.varia.LevelRangeFilter">
         <param name="LevelMin" value="ERROR" />
         <param name="LevelMax" value="FATAL" />
      </filter>
   </appender>
   
   
   

   <logger name="org.springframework">
      <level value="INFO" />
      <appender-ref ref="EMAIL"/>
      <appender-ref ref="SPRING" />
      <appender-ref ref="ICOPE" />
      <appender-ref ref="CONSOLE" />
   </logger>

   <logger name="org.hibernate">
      <level value="INFO" />
      <appender-ref ref="EMAIL"/>
      <appender-ref ref="CONSOLE" />
      <appender-ref ref="ICOPE" />
   </logger>
   
   

   <root>
      <priority value="ERROR" />
      <appender-ref ref="EMAIL"/>
      <appender-ref ref="CONSOLE" />
      <appender-ref ref="ICOPE" />
   </root>

</log4j:configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 11:10 am 
Newbie

Joined: Fri Oct 13, 2006 10:43 am
Posts: 3
The problem is that I have to use the log4j.cfg file so I can't use xml... Do you maybe have a solution for a cfg file?


Top
 Profile  
 
 Post subject: Log4j
PostPosted: Fri Oct 13, 2006 11:18 am 
Newbie

Joined: Fri Aug 04, 2006 3:01 pm
Posts: 13
Although I never used Websphere, Log4j will find your log4j.xml at the root of the class path by himself, so you can just delete your log4j.cfg and replace it with a log4j.xml file. Of course, this only works if the use of the .cfg format is not mandatory because of Websphere.

If so, you could try to adapt my config to a .cfg format. Sadly, I can't help you with that, since I really prefer .xml config and has worked with this format since, well, ever.



Don't forget to rate !!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 5:34 am 
Newbie

Joined: Fri Oct 13, 2006 10:43 am
Posts: 3
Anyone who also dealt with this problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.