Administration | Version 4

Logging - Useful Logback Configurations

Logging - Useful Logback Configurations

Introduction

This document lists useful logging configurations for the Sophora Server and tools. The Sophora Server and most of the tools use the Logback framework for log output. The following snippets are meant to be added to the logback.xml file of the server or the tools.

Writing output to a separate log file

The following example configuration writes log messages by the LoggingProfiler to a separate log file called "profile.log". The attribute additivity in the logger configuration controls whether the log messages are written to the main log file in addition to the profile.log.

<appender name="profile" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <File>${sophora.home}/logs/profile.log</File>
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <fileNamePattern>${sophora.home}/logs/profile.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
    <maxHistory>7</maxHistory>
  </rollingPolicy>
  <encoder>
    <pattern>[%d{ISO8601}, %-5p] [%t] [IP: %X{IP}] [UUID: %X{uuid}] [SOPHORA_ID: %X{sophora_id}] [USER: %X{user}] %m%n</pattern>
  </encoder>
</appender>

<logger name="com.subshell.sophora.commons.profile.LoggingProfiler" level="DEBUG" additivity="false">
  <appender-ref ref="profile" />
</logger>

Using a format pattern variable

A format pattern can be defined in a variable and then be reused in multiple appenders. The format is documented in the logback manual. The following example defines a variable APPENDER_PATTERN, which is then used in an appender.

<property name="APPENDER_PATTERN" value="%d{dd.MM.yyyy HH:mm:ss} %5level [%10.10thread] %-40.40(%logger{0}:%L): %msg%n" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  <encoder>
    <pattern>${APPENDER_PATTERN}</pattern>
  </encoder>
</appender>

Sophora Server

All calls on the ContentManager API, including execution times. See also Activating the profile log.

<logger name="com.subshell.sophora.commons.profile.LoggingProfiler" level="DEBUG" />

All SOLR queries, including connections made directly to the SOLR server:

<logger name="org.apache.solr.core.SolrCore" level="INFO" />

All JCR / XPath searches:

<logger name="com.subshell.sophora.server.application.manager.search.jcr.XpathSearchManager" level="DEBUG" />

IQuery SOLR searches executed by the server:

<logger name="com.subshell.sophora.server.application.manager.search.solr.SolrSearchStrategy" level="DEBUG" />

Server script executions, including execution times:

<logger name="com.subshell.sophora.server.application.scripting.jmx.ScriptingStatistics" level="DEBUG" />

Logging by document change scripts which use the logger from the IScriptContext:

<logger name="com.subshell.sophora.server.application.scripting.ScriptManager" level="DEBUG" />

Logging by timing scripts which use the logger from the ITimingActionScriptContext:

<logger name="com.subshell.sophora.server.application.timingaction.DocumentTimingActionsJob" level="INFO" />

Tools / Webapps

All calls on the ISophoraClient API, including execution times:

<logger name="com.subshell.sophora.client.profiling.SophoraClientProfiling" level="TRACE" />

All calls from the Sophora Client library to the Sophora server, including execution times:

<logger name="com.subshell.sophora.client.profiling.ContentManagerProfiling" level="TRACE" />

DeskClient

To show debug output of a client script in the DeskClient log, add the following code to the script:

import org.slf4j.LoggerFactory
import ch.qos.logback.classic.Logger
import ch.qos.logback.classic.Level
 
Logger logger = LoggerFactory.getLogger(this.getClass())
logger.setLevel(Level.DEBUG)

Last modified on 10/16/20

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon