Tag: log4j
Log4j levels
by Frank Kim on May.27, 2008, under Logging
I always forget which level is which in Log4j so I copied this from the JavaDoc for the Level class.
static Level |
ALLThe ALL has the lowest possible rank and is intended to turn on all logging. |
static Level |
DEBUGThe DEBUG Level designates fine-grained informational events that are most useful to debug an application. |
static Level |
ERRORThe ERROR level designates error events that might still allow the application to continue running. |
static Level |
FATALThe FATAL level designates very severe error events that will presumably lead the application to abort. |
static Level |
INFOThe INFO level designates informational messages that highlight the progress of the application at coarse-grained level. |
static Level |
OFFThe OFF has the highest possible rank and is intended to turn off logging. |
static Level |
TRACEThe TRACE Level designates finer-grained informational events than the DEBUG |
static Level |
WARNThe WARN level designates potentially harmful situations. |
How to Log SQL on JBoss
by Frank Kim on Apr.04, 2006, under Hibernate, JBoss, JDBC, Logging
Edit the log4j.xml in the conf directory as shown below to turn on SQL debugging of the JDBC CMP plugin.
/apps/jboss/server/default/conf :->diff -c log4j.xml~ log4j.xml
*** log4j.xml~ Mon Sep 30 18:09:27 2002
--- log4j.xml Tue Apr 4 20:41:18 2006
***************
*** 61,73 ****
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
! <param name="Threshold" value="INFO"/>
<param name="Target" value="System.out"/>
<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>
--- 61,79 ----
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
! <!--<param name="Threshold" value="INFO"/>-->
! <param name="Threshold" value="DEBUG"/>
<param name="Target" value="System.out"/>
<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>
+
+ <category name="org.jboss.ejb.plugins.cmp.jdbc">
+ <priority value="DEBUG"/>
+ </category>
+
</appender>
If you want to log Hibernate SQL statements:
<category name="org.hibernate.SQL">
<priority value="DEBUG"/>
</category>
If you want to log everything Hibernate’s doing, including SQL statements, schema export, transactions, etc.:
<category name="org.hibernate.SQL">
<priority value="DEBUG"/>
</category>