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:
-
appenderelements define the "output device" for the log. The main appenders areFILEandCONSOLE. TheThresholdparameter of the appender defines the message threshold. By default, it isDEBUGfor a file andINFOfor console. It means thatERROR,WARN,INFOandDEBUGmessages are written to a file, whileERROR,WARNandINFOare written to console.The path to the log file for the file appender is defined in the
Fileparameter;Appendflag defines if the file should be flushed or appended to at server restart. The default settings aretomcat/logs/app.logand flush at restart. When an application is in production, we recommend settingAppendtotrue.By default, the file appender is implemented by the
org.apache.log4j.DailyRollingFileAppenderclass, 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. -
categoryelements 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.samplecategory have effect on thecom.company.sample.core.CustomerServiceBeanandcom.company.sample.web.CustomerBrowseloggers, if the loggers do not explicitly override the settings with their own.Minimum logging level is defined by the
priorityelement. For example, if the category isINFO, thenDEBUGandTRACEmessages 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 > screen available in the web client. Any changes to the logging settings are effective only during server runtime and are
not saved to a file. The screen also allows viewing and loading log files from the server 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

