Logging

Cadenza includes a default logging configuration in its distribution and Docker container that contains sensible defaults. Here we show the default logging configuration for reference and inspiration. If you want to supply your own logging configuration see Environment Variables, System Properties and Other Runtime Configuration Options for the relevant properties.

We also have several variables defined in our configuration that you can easily override using environment variables to make certain subsystems of Cadenza log more information for debugging purposes. See Subsystem Loglevels.

If you set the log level below WARN you may trigger a significant amount of log output. Starting with the DEBUG level and lower, so much information is logged that it will seriously impact performance of Cadenza. DEBUG and below should never be used in production for a sustained period.

Subsystem Loglevels

The following table lists environment variables with which you can set the log level for certain important subsystems. By default, they will be set to ERROR, but you can override them to any of the following log4j2 log levels: TRACE, DEBUG, INFO, WARN, ERROR and FATAL.

Note that a lower log level will automatically include higher level log messages. A message logged with level WARN will also be output if the log level is set to DEBUG for example.

One typical use case would be to switch a particular subsystem to DEBUG to get more output for diagnosing a problem.

Environment Variable Purpose

CADENZA_LOGGING_MONITOR_INTERVAL

Set to 0 for never checking for changes on the logging configuration. Values other than 0 will trigger a reload of the configuration every n seconds.

CADENZA_LOGGING_DISABLE_CONSOLE_APPENDER

Set to true to disable the console appender. The default behaviour is thus that there is a console appender.

CADENZA_LOGGING_DISABLE_ROLLINGFILE_APPENDER

Set to true to disable the rolling file appender. The default behaviour is thus that there is a rolling file appender.

CADENZA_LOGGING_ROLLINGFILE_APPENDER_SIZE_TRIGGER

Set to a value like 50 MB to specify the size at which a rollover should be triggered. See https://logging.apache.org/log4j/2.x/manual/appenders/rolling-file.html#SizeBasedTriggeringPolicy for a description of the allowed syntax. The default is 50 MB.

CADENZA_LOGGING_ENABLE_SYSLOG_APPENDER

Set to true to enable a syslog appender. The default behaviour is that there is no syslog appender.

CADENZA_LOGGING_SYSLOG_APPENDER_HOST

This sets the target host for the syslog appender. The default is localhost.

CADENZA_LOGGING_SYSLOG_APPENDER_PORT

This sets the target port for the syslog appender. The default is 5140.

CADENZA_LOGGING_SYSLOG_APPENDER_PROTOCOL

This sets the protocol for the syslog appender. The default is UDP and the only possible values are UDP or TCP.

CADENZA_LOGGING_SYSLOG_APPENDER_EVENT_TEMPLATE_URI

This defines the URI for the syslog log layout. You can use any of the layouts defined by log4j2 internally (see https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#event-templates for other bundled layouts). If you want you use your own layout you need to ensure that the file can be accessed by Log4j2. The default is classpath:EcsLayout.json.

CADENZA_LOGLEVEL_OUTGOING_HTTP

Set to DEBUG to log all metadata (HTTP Headers, SSL connection details, etc) of HTTP requests such as WMS, WFS, WMTS and similar requests.

This will produce a lot of output and should not be used in production.

CADENZA_LOGLEVEL_OUTGOING_HTTP_WIRE

Set to DEBUG to log all contents of outgoing HTTP requests such as WMS, WFS, WMTS and similar requests.

This will produce a lot (really, an astonishing amount) of output and should not be used in production.

CADENZA_LOGLEVEL_CLUSTER

Set to DEBUG to log all messages exchanged between cluster nodes and very detailed Apache Ignite logging.

This will produce a lot of output and should not be used in production.

JSON Logging

Cadenza includes the required log4j2 dependency to enable JSON format logging. See the Apache Log4j2 configuration page for more details on how to configure this.

Default Configuration

We include our log4j2 logging configuration file as a reference if you need to verify something or (in rare cases) override the file completely:

Click to see XML file contents
<?xml version="1.0" encoding="UTF-8"?>

<!-- 'strict' must be 'true', changing this will lead to silent failures. See also:
      https://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax -->

<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_MONITOR_INTERVAL` | Set to `0` for never checking for changes on the logging configuration.
  Values other than `0` will trigger a reload of the configuration every n seconds.
end::cadenza-logging[] -->
<Configuration strict="true" monitorInterval="${env:CADENZA_LOGGING_MONITOR_INTERVAL:-0}">
  <!-- This defines a property to set the path for the cadenza web log file. By default it is set
       to the Tomcat logs directory. If you want to override this path, you can set the
       `CADENZA_LOG_PATH` environment variable. -->
  <Properties>
    <Property name="CADENZA_LOG_PATH">${sys:catalina.home}/logs</Property>
  </Properties>
  <!-- The appenders define where the output of the log goes, by default we log to the console
       and to a rolling file. -->
  <Appenders>
    <Select>
<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_DISABLE_CONSOLE_APPENDER` | Set to `true` to disable the console appender. The default
  behaviour is thus that there is a console appender.
end::cadenza-logging[] -->
      <EnvironmentArbiter propertyName="CADENZA_LOGGING_DISABLE_CONSOLE_APPENDER" propertyValue="true" />
      <DefaultArbiter>
        <Appender type="Console" name="console">
          <Layout type="PatternLayout" pattern="%d{ISO8601} %-5p [%t] %-c - %m%n" />
        </Appender>
      </DefaultArbiter>
    </Select>
    <Select>
<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_DISABLE_ROLLINGFILE_APPENDER` | Set to `true` to disable the rolling file appender. The default
  behaviour is thus that there is a rolling file appender.
end::cadenza-logging[] -->
      <EnvironmentArbiter propertyName="CADENZA_LOGGING_DISABLE_ROLLINGFILE_APPENDER" propertyValue="true" />
      <DefaultArbiter>
        <Appender
            type="RollingFile"
            name="delegate"
            fileName="${env:CADENZA_LOG_PATH}/cadenza-web.log"
            filePattern="${env:CADENZA_LOG_PATH}/cadenza-web-%d{yyyy-MM-dd}.%i.log">
          <Layout type="PatternLayout" pattern="%d{ISO8601} %-5p [%t] %-c - %m%n" />
          <Policies>
            <!-- The SizeBasedTriggeringPolicy makes sure that individual files are never larger than the configured size.
                 If they grow bigger, they will be rolled over to a new file. The filename contains an index that will be
                 incremented. Together with the DefaultRolloverStrategy max files setting this limits the maximum amount
                 of space these log files can take. -->

<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_ROLLINGFILE_APPENDER_SIZE_TRIGGER` | Set to a value like `50 MB` to specify the size at
  which a rollover should be triggered. See https://logging.apache.org/log4j/2.x/manual/appenders/rolling-file.html#SizeBasedTriggeringPolicy
  for a description of the allowed syntax. The default is `50 MB`.
end::cadenza-logging[] -->
            <SizeBasedTriggeringPolicy size="${env:CADENZA_LOGGING_ROLLINGFILE_APPENDER_SIZE_TRIGGER:-50 MB}" />
            <!-- Together with the date pattern in the filePattern attribute of the Appender which has a minimal granularity
                 of days this means that the log file will roll over to a new file each day. -->
            <TimeBasedTriggeringPolicy interval="1"/>
          </Policies>
          <!-- The value of the max attribute indicates how many files should be kept at most. Additional files will be
               deleted automatically starting with the oldest one. -->
          <DefaultRolloverStrategy max="20" />
        </Appender>
      </DefaultArbiter>
    </Select>
<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_ENABLE_SYSLOG_APPENDER` | Set to `true` to enable a syslog appender. The default
  behaviour is that there is no syslog appender.
end::cadenza-logging[] -->
    <EnvironmentArbiter propertyName="CADENZA_LOGGING_ENABLE_SYSLOG_APPENDER" propertyValue="true">
<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_SYSLOG_APPENDER_HOST` | This sets the target host for the syslog appender. The default is
  `localhost`.
| `CADENZA_LOGGING_SYSLOG_APPENDER_PORT` | This sets the target port for the syslog appender. The default is
  `5140`.
| `CADENZA_LOGGING_SYSLOG_APPENDER_PROTOCOL` | This sets the protocol for the syslog appender. The default is
  `UDP` and the only possible values are `UDP` or `TCP`.
end::cadenza-logging[] -->
      <Syslog name="syslog" host="${env:CADENZA_LOGGING_SYSLOG_APPENDER_HOST:-localhost}" port="${env:CADENZA_LOGGING_SYSLOG_APPENDER_PORT:-5140}" protocol="${env:CADENZA_LOGGING_SYSLOG_APPENDER_PROTOCOL:-UDP}">
<!-- tag::cadenza-logging[]
| `CADENZA_LOGGING_SYSLOG_APPENDER_EVENT_TEMPLATE_URI` | This defines the URI for the syslog log layout. You can
  use any of the layouts defined by log4j2 internally (see https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#event-templates
  for other bundled layouts). If you want you use your own layout you need to ensure that the file can be
  accessed by Log4j2. The default is `classpath:EcsLayout.json`.
end::cadenza-logging[] -->
        <JsonTemplateLayout eventTemplateUri="${env:CADENZA_LOGGING_SYSLOG_APPENDER_EVENT_TEMPLATE_URI:-classpath:EcsLayout.json}">
          <EventTemplateAdditionalField key="source" value="cadenza-logs"/>
        </JsonTemplateLayout>
      </Syslog>
    </EnvironmentArbiter>
  </Appenders>
  <!-- Now that we have defined where we will log things, we now configure _what_ will be logged -->
  <Loggers>
    <!-- By default, every library and every Cadenza subsystem should only log ERROR entries or worse.
         This prevents a lot of unnecessary output.
         Individual areas in Cadenza will (and can) be set to more verbose logging levels.          -->
    <Root level="ERROR">
      <Select>
        <EnvironmentArbiter propertyName="CADENZA_LOGGING_DISABLE_CONSOLE_APPENDER" propertyValue="true" />
        <DefaultArbiter>
          <AppenderRef ref="console"/>
        </DefaultArbiter>
      </Select>
      <Select>
        <EnvironmentArbiter propertyName="CADENZA_LOGGING_DISABLE_ROLLINGFILE_APPENDER" propertyValue="true" />
        <DefaultArbiter>
          <AppenderRef ref="delegate"/>
        </DefaultArbiter>
      </Select>
      <EnvironmentArbiter propertyName="CADENZA_LOGGING_ENABLE_SYSLOG_APPENDER" propertyValue="true">
        <AppenderRef ref="syslog"/>
      </EnvironmentArbiter>
    </Root>
    <!-- Spring is set to WARN to get a bit more actionable output -->
    <Logger name="org.springframework" level="WARN" />
    <!-- All Cadenza code starts with one of the following package prefixes and we set all of them
         to the level WARN or higher. This should produce only log output that is actionable for an
         administrator. -->
    <Logger name="de.disy" level="WARN" />
    <Logger name="gis.gisterm" level="WARN" />
    <Logger name="net.disy" level="WARN" />
    <!-- A few basic subsystems in Cadenza provide useful information at startup and we increase
         the loglevel for them to INFO so we can see it. -->
    <!-- Log Cadenza version information and encoding settings -->
    <Logger name="net.disy.cadenza.platform.PlatformFactory" level="INFO" />
    <!-- Log the Cadenza license -->
    <Logger name="net.disy.cadenza.core.license.module.WebLicenseFactoryAdapter" level="INFO" />
    <!-- Log the configuration format if it is specified -->
    <Logger name="de.disy.cadenza.core.config.items.logging.CadenzaConfigurationFormatLogger" level="INFO" />

    <!-- Below are logging configurations that are meant for admins to enable or disable using environment
         variables. They are documented in a special format so they can show up in our admin docs. -->

<!-- tag::cadenza-logging[]
| `CADENZA_LOGLEVEL_OUTGOING_HTTP` | Set to `DEBUG` to log all metadata (HTTP Headers, SSL connection details, etc)
 of HTTP requests such as WMS, WFS, WMTS and similar requests.

WARNING: This will produce a lot of output and should not be used in production.
end::cadenza-logging[] -->
    <Logger name="net.disy.lib.http.HttpRequestExecutor" level="${env:CADENZA_LOGLEVEL_OUTGOING_HTTP:-ERROR}" />
    <Logger name="org.apache.http" level="${env:CADENZA_LOGLEVEL_OUTGOING_HTTP:-ERROR}" />
<!-- tag::cadenza-logging[]
| `CADENZA_LOGLEVEL_OUTGOING_HTTP_WIRE` | Set to `DEBUG` to log all **contents** of outgoing HTTP requests such as WMS, WFS,
WMTS and similar requests.

WARNING: This will produce a lot (really, an astonishing amount) of output and should not be used in production.
end::cadenza-logging[] -->
    <Logger name="org.apache.http.wire" level="${env:CADENZA_LOGLEVEL_OUTGOING_HTTP_WIRE:-ERROR}"/>
<!-- tag::cadenza-logging[]
| `CADENZA_LOGLEVEL_CLUSTER` | Set to `DEBUG` to log all messages exchanged between cluster nodes and
very detailed Apache Ignite logging.

WARNING: This will produce a lot of output and should not be used in production.
end::cadenza-logging[] -->
    <Logger name="net.disy.cadenza.message.broker.ignite" level="${env:CADENZA_LOGLEVEL_CLUSTER:-ERROR}" /> <!-- this will also allow to see all the messages exchanged with given node -->
    <Logger name="org.apache.ignite" level="${env:CADENZA_LOGLEVEL_CLUSTER:-ERROR}" />
  </Loggers>
</Configuration>