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.  [ 9 posts ] 
Author Message
 Post subject: cant see sql parameters (in jboss , log4j.xml)
PostPosted: Mon Jul 16, 2007 12:45 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
Hey,

I am using Jboss server.
I add to jboss.lo4j the following categories:

Code:
   <category name="org.hibernate">
      <priority value="DEBUG"/>
      <appender-ref ref="APPLICATIONNAME_FILE" />
   </category>
   
   <!-- Log SQL statements-->
   <category name="org.hibernate.SQL">
      <priority value="DEBUG"/>
      <appender-ref ref="APPLICATIONNAME_FILE" />
   </category>
   
   <!-- Log the values assigned to the SQL parameters and results -->
   <category name="org.hibernate.type">
      <priority value="DEBUG"/>
      <appender-ref ref="APPLICATIONNAME_FILE" />
   </category>


It prints the sql and other stuff , but it dosnt print the parameters.

Can you please help?

Thank you


Top
 Profile  
 
 Post subject: Does any one try to debud with log4j.xml?
PostPosted: Tue Jul 17, 2007 4:30 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
Does any one try to debud with log4j.xml?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 17, 2007 4:33 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
I have heard stories of this happening before -- specifically inside JBAS. I haven't found an explanation or a fix for it yet.

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 11:44 am 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
It turns out that org.hibernate.type.NullableType caches the "isTraceEnabled" value as a performance fix. This means that if you did not start your JBAS with org.hibernate.type=DEBUG it will never log at the DEBUG level. The code is commented as such:

http://anonsvn.jboss.org/repos/hibernat ... eType.java

Start your server with this setting already in log4j.xml and you should see the parameter bindings.

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject: This dosnt work
PostPosted: Tue Sep 11, 2007 1:26 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
Thank you for your answer.

But, this dosnt sove the problem.

it print the sql but without the binding params.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 1:47 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
Look in your JMX console and find the logging level for that category. It will tell you the REAL log level at runtime. It should be DEBUG. Are you sure you're looking at the right log file? Do your SQL's have "Hibernate:" in front of them? If so, you're seeing the old system.out SQL printing, not the one from Log4J.

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 1:52 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Folks, just put your log level for that category in TRACE. And drop that crap default jboss-log4j.xml file and replace it with this:

Code:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

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

    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
        <param name="Target" value="System.out"/>
        <layout class="org.apache.log4j.PatternLayout">
            <!-- The default pattern: Date Priority [Category] Message\n -->
            <param name="ConversionPattern" value="(%thread) %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
        </layout>
    </appender>

    <category name="org.hibernate">
        <priority value="INFO"/>
    </category>
    <category name="org.hibernate.SQL">
        <priority value="TRACE"/>
    </category>
    <category name="org.hibernate.type">
        <priority value="TRACE"/>
    </category>

    <root>
        <priority value="INFO"/>
        <appender-ref ref="CONSOLE"/>
    </root>

</log4j:configuration>

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 11:36 am 
Beginner
Beginner

Joined: Tue Sep 16, 2003 11:26 am
Posts: 25
Location: Berlin - Germany
@christian:

Thanks for your help.I used your log4j.xml without success: Still the same: sql is logged but no parameters.
I am using:
* Hibernate 3.1.3
* JBoss 4.0.5.GA
* Java 6
* Linux

Do you have any idea?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 11:58 am 
Beginner
Beginner

Joined: Tue Sep 16, 2003 11:26 am
Posts: 25
Location: Berlin - Germany
Strange: I tried it with JBoss-4.0.2/Java-1.4 and it works! JBoss is the bad boy...

log4j.xml:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
   <!-- ================================= -->
   <!-- Preserve messages in a local file -->
   <!-- ================================= -->
   
   <!-- A time/date based rolling appender -->
   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
      <param name="Append" value="false"/>
      <!-- Rollover at midnight each day -->
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      <!-- Rollover at the top of each hour
      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
      -->
      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] Message\n -->
         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
         -->
      </layout>
   </appender>

   <!-- ============================== -->
   <!-- Append messages to the console -->
   <!-- ============================== -->
   
   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="Target" value="System.out"/>
      <param name="Threshold" value="INFO"/>
      
      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] Message\n -->
         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
      </layout>
   </appender>

   <!-- ================ -->
   <!-- Limit categories -->
   <!-- ================ -->
   
  <category name="org.hibernate.SQL">
    <priority value="DEBUG"/>
  </category>
 
  <category name="org.hibernate.type">
    <priority value="DEBUG"/>
  </category>
   <!-- ======================= -->
   <!-- Setup the Root category -->
   <!-- ======================= -->

   <root>
      <!-- Log levels: DEBUG, INFO, WARN, ERROR -->
      <priority value="WARN"/>
      <!-- Logger: FILE, DEPLOY, HIBERNATE, PERSISTENCE, CONSOLE -->
      <appender-ref ref="FILE"/>
   </root>

</log4j:configuration>


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