Hibernate Logging
Logs are your best friend when it comes to Hibernate and its plethora of obscure error codes and situations. Hibernate is incredible until it's not. However, we definitely encourage you to tweak your server whenever you need deeper understanding of what's going on under the hood.

ORM Util Logging

We have provided a handy method in our ORM Utility object to help you set the logging level of hibernate globally and redirect the output of those logs to CommandBox (Lucee only for now). This must be done once the application loads in order to seed the levels and configuration and done only once. Therefore we recommend you update your Application.cfc with the following in the onApplicationStart() method
1
public boolean function onApplicationStart(){
2
3
// SETUP THE LOGGING
4
new cborm.models.util.ORMUtilSupport().setupHibernateLogging( "INFO" );
5
6
application.cbBootstrap = new coldbox.system.Bootstrap(
7
COLDBOX_CONFIG_FILE,
8
COLDBOX_APP_ROOT_PATH,
9
COLDBOX_APP_KEY,
10
COLDBOX_APP_MAPPING
11
);
12
application.cbBootstrap.loadColdbox();
13
return true;
14
}
Copied!
The setupHibernateLogging( level ) method accepts a logging level so you can control the output of the logs.
Level
Description
ALL
All levels including custom levels.
DEBUG
Designates fine-grained informational events that are most useful to debug an application.
INFO
Designates informational messages that highlight the progress of the application at coarse-grained level.
WARN
Designates potentially harmful situations.
ERROR
Designates error events that might still allow the application to continue running.
FATAL
Designates very severe error events that will presumably lead the application to abort.
OFF
The highest possible rank and is intended to turn off logging.
TRACE
Designates finer-grained informational events than the DEBUG.
This basic setup will get you to almost 90% of all your logging needs.

Lucee Location Logs

The log files for hibernate are located in the following locations for Lucee:
1
# Web Context Logs
2
{engine}/WEB-INF/lucee-web/orm.log
3
# Server Context Logs
4
{engine}/WEB-INF/lucee-server/context/logs/orm.log
Copied!
Please note that if you use the setupHibernateLogging() then all the log output shoudl appear in the CommandBox out logs.

Adobe Logging

In Adobe engines you can also tweak the log4j configuration to get even more out of your logs. Let's start with the most important question, where are they?
1
{engine}/WEB-INF/cfusion/logs/hibernatesql.log
Copied!
Ok, now the file we need to update to fine tune our logging is:
1
{engine}/WEB-INF/cfusion/lib/log4j.properties
Copied!
The file is self explanatory and we have reviewed the log4j levels before, so just get in there and make stuff happen. Here is our full debugging resource we use for ContentBox CMS Development:
1
# Set root category priority to INFO and its only appender to CONSOLE.
2
log4j.rootCategory=INFO,CONSOLE
3
#log4j.rootCategory=INFO, CONSOLE, LOGFILE
4
5
### setup ESAPI Log
6
log4j.logger.org.owasp.esapi=ERROR, ESAPILOGFILE
7
log4j.additivity.org.owasp.esapi=false
8
9
### Setup Axis Log
10
log4j.logger.org.apache.axis=WARN, AXISCONSOLE
11
log4j.additivity.org.apache.axis=false
12
13
### Setup Axis2 Log
14
log4j.logger.org.apache.axis2=ERROR, AXIS2CONSOLE
15
log4j.additivity.org.apache.axis2=false
16
17
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
18
log4j.logger.org.apache.axis.enterprise=FATAL, AXISCONSOLE
19
20
### Setup JetS3t Log
21
log4j.logger.org.jets3t.service=ERROR, CONSOLE
22
23
24
###--------------- ORTUS Hibernate Log Settings ------
25
### Set Hibernate log
26
log4j.logger.org.hibernate=INFO, HIBERNATECONSOLE
27
28
### log just the SQL
29
log4j.logger.org.hibernate.SQL=DEBUG, HIBERNATECONSOLE
30
log4j.additivity.org.hibernate.SQL=true
31
### Also log the parameter binding to the prepared statements.
32
log4j.logger.org.hibernate.type=DEBUG
33
34
35
### log schema export/update ###
36
log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG, HIBERNATECONSOLE
37
38
### log cache activity ###
39
log4j.logger.org.hibernate.cache=WARN, HIBERNATECONSOLE
40
#---------------------------------------------
41
42
###--------------- Jetty Log Settings ------
43
### Set Jetty log
44
log4j.logger.org.eclipse.jetty=ERROR, JETTYCONSOLE
45
46
log4j.logger.net.sf.ehcache=ERROR
47
48
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
49
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
50
log4j.appender.CONSOLE.Threshold=INFO
51
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
52
log4j.appender.CONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] %-5p %m%n
53
54
# AXISCONSOLE is set to be a ConsoleAppender for Axis using a PatternLayout.
55
log4j.appender.AXISCONSOLE=org.apache.log4j.ConsoleAppender
56
log4j.appender.AXISCONSOLE.layout=org.apache.log4j.PatternLayout
57
log4j.appender.AXISCONSOLE.layout.ConversionPattern=%d [%t] AXIS %-5p %c - %m%n
58
59
# AXIS2CONSOLE is set to be a File appender using a PatternLayout.
60
log4j.appender.AXIS2CONSOLE= org.apache.log4j.FileAppender
61
log4j.appender.AXIS2CONSOLE.File=${coldfusion.rootDir}/logs/axis2.log
62
log4j.appender.AXIS2CONSOLE.Append=true
63
log4j.appender.AXIS2CONSOLE.layout=org.apache.log4j.PatternLayout
64
log4j.appender.AXIS2CONSOLE.layout.ConversionPattern=%d [%t] AXIS2 %-5p %c - %m%n
65
66
# LOGFILE is set to be a File appender using a PatternLayout.
67
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
68
log4j.appender.LOGFILE.File=axis.log
69
log4j.appender.LOGFILE.Append=true
70
log4j.appender.LOGFILE.Threshold=INFO
71
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
72
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
73
74
# ESAPICONSOLE is set to be a ConsoleAppender for ESAPI using a PatternLayout.
75
log4j.appender.ESAPILOGFILE= org.apache.log4j.FileAppender
76
log4j.appender.ESAPILOGFILE.File=${coldfusion.rootDir}/logs/esapiconfig.log
77
log4j.appender.ESAPILOGFILE.Append=true
78
log4j.appender.ESAPILOGFILE.layout=org.apache.log4j.PatternLayout
79
log4j.appender.ESAPILOGFILE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] ESAPI %-5p - %m%n%n
80
81
# HibernateConsole is set to be a RollingFileAppender for Hibernate message using a PatternLayout.
82
log4j.appender.HIBERNATECONSOLE= org.apache.log4j.RollingFileAppender
83
log4j.appender.HIBERNATECONSOLE.File=${coldfusion.rootDir}/logs/hibernatesql.log
84
log4j.appender.HIBERNATECONSOLE.Append=true
85
log4j.appender.HIBERNATECONSOLE.MaxFileSize=5000KB
86
log4j.appender.HIBERNATECONSOLE.MaxBackupIndex=3
87
log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout
88
log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] HIBERNATE %-5p - %m%n%n
89
90
# JETTYCONSOLE is set to be a ColsoleAppender for jetty message using a PatternLayout.
91
log4j.appender.JETTYCONSOLE=org.apache.log4j.ConsoleAppender
92
log4j.appender.JETTYCONSOLE.layout=org.apache.log4j.PatternLayout
93
log4j.appender.JETTYCONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] JETTY %-5p - %m%n%n
94
95
# For Quartz logging
96
log4j.logger.org.quartz=ERROR
97
log4j.logger.org.apache=ERROR
Copied!
Last modified 1mo ago
Export as PDF
Copy link
Edit on GitHub