/
Example: Logging configuration for JSON logging

Example: Logging configuration for JSON logging

The logging configuration is already included in the product since tia® Core Content server 3.4.0.

To activate, simply set parameter logging.config parameter to value /application/config/json-logback.xml.

 

Logging configuration for JSON logging

This example demonstrates how to set up tia Content Server to standard out, while all log rows are JSON objects. A JSON parser in a log analyser software can then extract the information pieces.

 

The stdout appender (line 4-29) defines

  • the encoder, with the providers to build the JSON object per log row (line 3 to 28).

The provider mdc is the mapped diagnostic context, which for tia Core product includes the field TraceId and SpanId. For more information, read https://kgs-software.atlassian.net/wiki/spaces/SUPPORT/pages/3661987841.

 

The root tag is the main point to load these specifications. Here,

  • the default root log level is set, as well as

  • the appender bound for logging.

The root log level can be set as well by application-wide parameter logging.level.root.

It is possible to bind declare and bind multiple appenders in the logging configuration file.

 

Example logging configuration file

<configuration> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"> <providers> <timestamp> <fieldName>timestamp</fieldName> <timeZone>UTC</timeZone> </timestamp> <loggerName> <fieldName>logger</fieldName> </loggerName> <logLevel> <fieldName>level</fieldName> </logLevel> <threadName> <fieldName>thread</fieldName> </threadName> <nestedField> <fieldName>mdc</fieldName> <providers> <mdc /> </providers> </nestedField> <stackTrace> <fieldName>stackTrace</fieldName> <!-- maxLength - limit the length of the stack trace --> <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter"> <maxDepthPerThrowable>200</maxDepthPerThrowable> <maxLength>14000</maxLength> <rootCauseFirst>true</rootCauseFirst> </throwableConverter> </stackTrace> <message /> <throwableClassName> <fieldName>exceptionClass</fieldName> </throwableClassName> </providers> </encoder> </appender> <root level="info"> <appender-ref ref="stdout" /> </root> </configuration>

 

Related content

Example: Logging configuration to standard out
Example: Logging configuration to standard out
More like this
Configuration of logging framework in WAR file deployments.
Configuration of logging framework in WAR file deployments.
More like this
Example: Logging configuration for rolling log file
Example: Logging configuration for rolling log file
More like this
Configuration of logging framework in container deployment
Configuration of logging framework in container deployment
More like this
Example: Logging configuration for Email notification
Example: Logging configuration for Email notification
More like this
Change Log Level on Runtime
Change Log Level on Runtime
More like this