Configuring logging for a Content Delivery Server Role
You already set up logging when you installed your Server Roles. But you can configure logging in more detail by editing the logback.xml, the configuration file for the Logback logging framework used by Content Delivery.
About this task
For detailed information about the Logback framework and its configuration, refer to http://logback.qos.ch/documentation.html.
Procedure
- In the location of the Server Role for which you want to activate logging, open
logback.xmlfor editing. This file is located in the bin\config\ (.NET) or WEB-INF/classes/ (Java) subfolder of your Web application, or in the root of your Server Role running as a microservice. - Set the following properties:
<property name="log.pattern" value="%date %-5level %logger{0} - %message%n"/> <property name="log.history" value="7"/> <property name="log.folder" value="c:/tridion/log"/> <property name="log.level" value="WARN"/> <property name="log.encoding" value="UTF-8"/>log.pattern(logging output format)-
The
log.patternproperty specifies the appearance of log messages using a format string. For example, a log pattern%date %-5level %logger{0} - %message%nwould result in messages such as this one:2013-03-11 16:55:34,137 DEBUG AmbientDataContext - Setting current ambient data context: com.tridion.ambientdata.web.WebContext. Refer to the online Logback documentation for more information. log.history(number of log files)-
The
log.historyproperty specifies the number of log files to back up (the default is 7 files). log.folder(logging location)-
The
log.folderproperty specifies the location where log files are saved (defaults to c:/Tridion/log). -
For example, on the Content Manager Server, set the log location to TRIDION_HOME/log, where TRIDION_HOME is the value of the
%TRIDION_HOME%environment variable, with the backslashes replaced with forward slashes. By default, the value is c:/Program Files/SDL Web/. If your system was upgraded from a release before SDL Web 8, the value defaults to c:/Program Files/Tridion. log.level(logging level)-
To change the default logging level, change the value of the
log.levelproperty to one of the values describes in the following table. Note that logging levels are incremental and inclusive; each level logs data for the previous levels. For example,DEBUGalso logs and events covered byINFO,WARN, andERROR.Logging Level Description OFFTurn off logging. ERROR(default)Log events that cause a specific feature of the application to fail. WARNLog events that are potentially harmful. INFOLog neutral, informational messages about high-level functionality being executed. DEBUGLog fine-grained informational messages about low-level functionality being executed, intended to discover the source of a problem. TRACELog highly detailed informational messages about the application's lowest-level activity, ALLMaximum logging level that logs everything. Note: TheDEBUGlevel is intended for hunting down the origin of a particular problem only and will result in a significant performance drop while this level is set. Therefore, it is recommended to set the logging level back to as soon as the problem has been resolved. log.encoding(logging encoding)-
The encoding used when writing log files. For example,
UTF-16.
- If you want to use property substitutions, that is, variables resolved by context such as environment variables, the Logback framework allows you to do so. The simplest way to do this is to define an environment variable (say
Foo) wherever you set up Content Delivery, and insert the string${Foo}in your logging configuration file. Logback now substitutes the string with the value of the environment variable. This approach enables you to reuse the same configuration file (and, say, deploy a WAR file without having to edit this file). For more information, refer to the heading "Property substitution" on this Web page: http://logback.qos.ch/manual/configuration.html. - If you want to enable Logback to apply your configuration changes without having to restart your Web application, use the
scanandscanPeriodattributes in theconfigurationelement. Refer to http://logback.qos.ch/manual/configuration.html#autoScan. - Save and close
logback.xml. - Restart your Content Delivery Server Role by restarting the Web application or microservice.
Related concepts