Discussion:
Log4j not logging hibernate
wild_oscar
2007-11-02 15:55:23 UTC
Permalink
My current log4j properties file has the following input regarding Hibernate:

[code]
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=warn, stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=DEBUG
log4j.logger.org.hibernate=debug, stdout
log4j.logger.org.hibernate.SQL=debug, stdout
log4j.logger.org.hibernate.type=info, stdout
log4j.logger.org.hibernate.engine.QueryParameters=debug
[/code]

and the file is in the lib folder of my web application.

Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute

<property name="show_sql">true</property>

on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).

Can anyone help me understand what am I doing wrong for the hibernate not
being logged?
Thank you for your replies!
--
View this message in context: http://www.nabble.com/Log4j-not-logging-hibernate-tf4738349.html#a13550421
Sent from the Log4j - Users mailing list archive at Nabble.com.
Paul Smith
2007-11-03 04:46:21 UTC
Permalink
Post by wild_oscar
Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute
<property name="show_sql">true</property>
on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).
This is really a Hibernate question. If you actually dig into the
Hibernate source code you will find that it will not log anything
unless that Hibernate property is set. This is not something log4j
has control over.

cheers,

Paul Smith
wild_oscar
2007-11-03 12:42:32 UTC
Permalink
The hibernate docu says

show_sql: Write all SQL statements to console. This is an alternative to
setting the log category org.hibernate.SQL to debug

As an alternative, the org.hibernate.SQL log4j property should work. The
problem is that I am also interested in other org.hibernate.xxx logging
properties (that I cannot set in the hibernate config file).
Post by Paul Smith
Post by wild_oscar
Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute
<property name="show_sql">true</property>
on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).
This is really a Hibernate question. If you actually dig into the
Hibernate source code you will find that it will not log anything
unless that Hibernate property is set. This is not something log4j
has control over.
cheers,
Paul Smith
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Log4j-not-logging-hibernate-tf4738349.html#a13562544
Sent from the Log4j - Users mailing list archive at Nabble.com.
Paul Smith
2007-11-03 22:13:51 UTC
Permalink
Post by wild_oscar
The hibernate docu says
show_sql: Write all SQL statements to console. This is an
alternative to
setting the log category org.hibernate.SQL to debug
As an alternative, the org.hibernate.SQL log4j property should work. The
problem is that I am also interested in other org.hibernate.xxx logging
properties (that I cannot set in the hibernate config file).
Which particular events are you interested in seeing? From your
logging configuration in a previous mail you look like you're trying
to see logs from the QueryParameters? I've looked into the Hibernate
source code for QueryParameters and it doesn't log much, but what it
does log is at TRACE level, so you're going to need to do 2 things for
this one at least:

log4j.threshold=ALL
log4j.logger.org.hibernate.engine.QueryParameters=TRACE

cheers,

Paul
Jacob Kjome
2007-11-03 05:55:34 UTC
Permalink
The WEB-INF/lib folder is not added to the classpath. Each jar in said folder is
but not the folder itself. You need to put it in WEB-INF/classes. I assume you
are using Tomcat standalone, with child-first classloading? Then if you put
log4j.jar in WEB-INF/lib, it should pick up log4j.properties from WEB-INF/classes,
unless you have log4j.xml somewhere in the root package on the classpath, as
log4j.xml is used in preference to log4j.properties.


Jake
Post by wild_oscar
[code]
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=warn, stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=DEBUG
log4j.logger.org.hibernate=debug, stdout
log4j.logger.org.hibernate.SQL=debug, stdout
log4j.logger.org.hibernate.type=info, stdout
log4j.logger.org.hibernate.engine.QueryParameters=debug
[/code]
and the file is in the lib folder of my web application.
Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute
<property name="show_sql">true</property>
on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).
Can anyone help me understand what am I doing wrong for the hibernate not
being logged?
Thank you for your replies!
wild_oscar
2007-11-03 12:36:16 UTC
Permalink
I will try it, although I do not believe that should be a problem - I have my
Log Servlet set to pick up the log4j.properties file from the /lib
directory. And all other properties (for instance, changing the log level of
my custom packages) are working well (eg, turning off the log for my
packages works).
Post by Jacob Kjome
The WEB-INF/lib folder is not added to the classpath. Each jar in said folder is
but not the folder itself. You need to put it in WEB-INF/classes. I assume you
are using Tomcat standalone, with child-first classloading? Then if you put
log4j.jar in WEB-INF/lib, it should pick up log4j.properties from WEB-INF/classes,
unless you have log4j.xml somewhere in the root package on the classpath, as
log4j.xml is used in preference to log4j.properties.
Jake
Post by wild_oscar
[code]
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=warn, stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=DEBUG
log4j.logger.org.hibernate=debug, stdout
log4j.logger.org.hibernate.SQL=debug, stdout
log4j.logger.org.hibernate.type=info, stdout
log4j.logger.org.hibernate.engine.QueryParameters=debug
[/code]
and the file is in the lib folder of my web application.
Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute
<property name="show_sql">true</property>
on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).
Can anyone help me understand what am I doing wrong for the hibernate not
being logged?
Thank you for your replies!
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Log4j-not-logging-hibernate-tf4738349.html#a13562481
Sent from the Log4j - Users mailing list archive at Nabble.com.
Jacob Kjome
2009-08-25 04:01:00 UTC
Permalink
From reading some of the SLF4J posts, it seems that Hibernate uses SLF4J. Could
it be that you have to install the correct binding to route hibernate logs to Log4j?

Jake
Did u ever figure it out?
My custom packages logging is controlled fine but I cannot seem to control
anything from org.hibernate.
Same problem as yours.
Post by wild_oscar
I will try it, although I do not believe that should be a problem - I have
my Log Servlet set to pick up the log4j.properties file from the /lib
directory. And all other properties (for instance, changing the log level
of my custom packages) are working well (eg, turning off the log for my
packages works).
Post by Jacob Kjome
The WEB-INF/lib folder is not added to the classpath. Each jar in said folder is
but not the folder itself. You need to put it in WEB-INF/classes. I assume you
are using Tomcat standalone, with child-first classloading? Then if you put
log4j.jar in WEB-INF/lib, it should pick up log4j.properties from WEB-INF/classes,
unless you have log4j.xml somewhere in the root package on the classpath, as
log4j.xml is used in preference to log4j.properties.
Jake
Post by wild_oscar
[code]
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=warn, stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=DEBUG
log4j.logger.org.hibernate=debug, stdout
log4j.logger.org.hibernate.SQL=debug, stdout
log4j.logger.org.hibernate.type=info, stdout
log4j.logger.org.hibernate.engine.QueryParameters=debug
[/code]
and the file is in the lib folder of my web application.
Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute
<property name="show_sql">true</property>
on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).
Can anyone help me understand what am I doing wrong for the hibernate not
being logged?
Thank you for your replies!
---------------------------------------------------------------------
aabra1
2009-08-25 04:14:59 UTC
Permalink
thanks for the reply

I already figured it out.
It was conflicting logging jar files.
I had to pick and choose untill I had it right.
I have springMVC with Hibernate (connection pooling).
This is the jars that I have in my ...\WEB-INF\lib

c3p0-0.9.1.2.jar
antlr-2.7.6.jar
asm-2.2.3.jar
cglib-nodep-2.1_3.jar
dom4j-1.6.1.jar
jta.jar
persistence.jar
servlet-api.jar
commons-collections.jar
commons-pool.jar
log4j-1.2.15.jar
commons-logging.jar
ehcache-1.4.1.jar
slf4j-api-1.5.0.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
jstl.jar
mysql-connector-java-5.1.8-bin.jar
standard-1.1.2.jar
spring-webmvc-2.5.6.jar
spring-context-2.5.6.jar
spring-2.5.6.jar
slf4j-log4j12-1.5.2.jar
From reading some of the SLF4J posts, it seems that Hibernate uses SLF4J.
Could
it be that you have to install the correct binding to route hibernate logs to Log4j?
Jake
Did u ever figure it out?
My custom packages logging is controlled fine but I cannot seem to control
anything from org.hibernate.
Same problem as yours.
Post by wild_oscar
I will try it, although I do not believe that should be a problem - I have
my Log Servlet set to pick up the log4j.properties file from the /lib
directory. And all other properties (for instance, changing the log level
of my custom packages) are working well (eg, turning off the log for my
packages works).
Post by Jacob Kjome
The WEB-INF/lib folder is not added to the classpath. Each jar in said folder is
but not the folder itself. You need to put it in WEB-INF/classes. I assume you
are using Tomcat standalone, with child-first classloading? Then if
you
put
log4j.jar in WEB-INF/lib, it should pick up log4j.properties from WEB-INF/classes,
unless you have log4j.xml somewhere in the root package on the
classpath,
as
log4j.xml is used in preference to log4j.properties.
Jake
Post by wild_oscar
[code]
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=warn, stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=DEBUG
log4j.logger.org.hibernate=debug, stdout
log4j.logger.org.hibernate.SQL=debug, stdout
log4j.logger.org.hibernate.type=info, stdout
log4j.logger.org.hibernate.engine.QueryParameters=debug
[/code]
and the file is in the lib folder of my web application.
Unfortunately, I cannot get any Hibernate logs on my tomcat logging file
unless I explicitly set the attribute
<property name="show_sql">true</property>
on my hibernate.cfg.xml file. (and I can't get my queryparameters, on which
I am interested in).
Can anyone help me understand what am I doing wrong for the hibernate not
being logged?
Thank you for your replies!
---------------------------------------------------------------------
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Log4j-not-logging-hibernate-tp13550421p25128019.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
Loading...