Running Gradle setupTomcat task installs the Tomcat server into the project directory and performs its additional configuration. Particularly, setenv.bat
and setenv.sh
files are created in the tomcat/bin
subfolder, and log4j.xml
is created in the tomcat/conf
subfolder.
Among other things, the setenv.*
files define loading parameters for the log4j.xml
configuration file using the CATALINA_OPTS
variable.
log4j.xml
defines logging configuration. The file has the following structure:
-
appender
elements define the "output device" for the log. The main appenders areFILE
andCONSOLE
. TheThreshold
parameter of the appender defines the message threshold. By default, it isDEBUG
for a file andINFO
for console. It means thatERROR
,WARN
,INFO
andDEBUG
messages are written to a file, whileERROR
,WARN
andINFO
are written to console.The path to the log file for the file appender is defined in the
File
parameter;Append
flag defines if the file should be flushed or appended to at server restart. The default settings aretomcat/logs/app.log
and flush at restart. When an application is in production, we recommend settingAppend
totrue
.By default, the file appender is implemented by the
org.apache.log4j.DailyRollingFileAppender
class, which renames the log file to a previous date and starts a new file daily at 00:00:00. This helps avoiding excessively large log files. -
category
elements define the logger parameters that are used to send messages from the program code. Category names are hierarchical, i.e. the settings of thecom.company.sample
category have effect on thecom.company.sample.core.CustomerServiceBean
andcom.company.sample.web.CustomerBrowse
loggers, if the loggers do not explicitly override the settings with their own.Minimum logging level is defined by the
priority
element. For example, if the category isINFO
, thenDEBUG
andTRACE
messages will not be logged. It should be kept in mind that message logging is also affected by the level threshold set in the appender.
You can quickly change category levels and appender thresholds for a running server using the logs folder (tomcat/logs
).
The platform automatically adds the following information to the messages written to a log:
-
[application]
– the name of the Tomcat-deployed web application whose code has logged the message. This information allows identifying messages from different application blocks (Middleware, Web Client), since they are written into the same file. -
[user]
– login name of the user who invoked the code logging the message. This helps to track activity of a certain user in the common log. If the code that logged a message was not invoked within a specific user session, the user information is not added.
For example, the following message has been written to the log by the code of the Middleware block (app-core
), running under the admin
user:
2013-12-19 18:48:17,282 DEBUG [com.haulmont.cuba.core.app.DataManagerBean] [app-core] [admin] loadList: metaClass=sec$User, view=com.haulmont.cuba.security.entity.User/user.browse, query=select u from sec$User u, max=100