6.5.1. Setting up Logging in Tomcat
Running Gradle setupTomcat task installs the Tomcat server into the project directory and performs its additional configuration. Particularly,
setenv.sh files are created in the
tomcat/bin subfolder, and
logback.xml is created in the
Among other things, the
setenv.* files define loading parameters for the
logback.xml configuration file using the
logback.xml defines logging configuration. The file has the following structure:
appenderelements define the "output device" for the log. The main appenders are
ThresholdFilterdefines the message threshold. By default, it is
DEBUGfor a file and
INFOfor console. It means that
DEBUGmessages are written to a file, while
INFOare written to console.
The path to the log file for the file appender is defined in the
fileparameter. The default is
loggerelements define the logger parameters that are used to print messages from the program code. Logger names are hierarchical, i.e. the settings of the
com.company.samplelogger have effect on the
com.company.sample.web.CustomerBrowseloggers, if the loggers do not explicitly override the settings with their own.
Minimum logging level is defined by the
levelattribute. For example, if the category is
TRACEmessages 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 logger levels and appender thresholds for a running server using the * Administration* > Server log 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 enables viewing and loading log files from the server logs folder (tomcat/logs).
The platform automatically adds the following information to the messages written to the file log:
application – the name of the web application that has logged the message. This information enables identifying messages from different application blocks (Middleware, Web Client), since they are written into the same file.
user – the login name of the user who invoked the code logging the message. This helps to track activity of a certain user in the 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
16:12:20.498 DEBUG [http-nio-8080-exec-7/app-core/admin] com.haulmont.cuba.core.app.DataManagerBean - loadList: ...