You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Scope

  • JS7 makes use of Log4j2 for logging purposes. Log rotation is required to prevent log files from filling up disk space.
  • The default configuration includes to limit disk space consumption for each of Controller, Agent and JOC Cockpit to 6GB.
  • The configuration to rotate log files is similar for any JS7 components.

Log4j2 Configuration Files

The Log4j2 configuration file is log4j2.xml that is found with the following default locations:


WindowsUnix
ControllerC:\Program Files\sos-berlin.com\js7\controller\lib\log42j.xml/opt/sos-berlin.com/js7/controller/lib/log4j2,xml
AgentC:\Program Files\sos-berlin.com\js7\agent\lib\log42j.xml/opt/sos-berlin.com/js7/agent/lib/log4j2,xml
JOC CockpitC:\ProgramData\sos-berlin.com\js7\joc\jetty_base\resources\joc\log42j.xml/var/sos-berlin.com/js7/joc/jetty_base/resources/joc/log4j2,xml

Log Rotation Strategy

By default log files are rotated on the following events:

  • if the size of a log file exceeds 100 MB or
  • on day change.

If a log file is rotated then its name is appended the current date and a running number, in addition the log file is compressed, e.g. a log file controller.log becomes controller-2021-01-31-1.log.gz. The running number 1 indicates the first log file of the day being rotated.

Users are free to modify the Log4j2 configuration files to apply an individual log rotation strategy.

Log File Retention

By default the retention period for any log file is 30 days.

Configuration Files explained

Controller and Agent log4j2 Configuration

Controller, Agent log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN" shutdownHook="disable">
  <appenders>
    <console name="console" target="SYSTEM_ERR">
      <patternLayout pattern="%highlight{%d{EE HH:mm:ss.SSS} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message}{WARN=magenta}%n"/>
    </console>
    <rollingRandomAccessFile name="file"
                             fileName="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}.log"
                             filePattern="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}-%d{yyyy-MM-dd}-%i.log.gz"
                             immediateFlush="false">
      <patternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSSZ} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message%n"
                     charset="UTF-8"/>
      <policies>
        <onStartupTriggeringPolicy/>
        <timeBasedTriggeringPolicy/>
        <sizeBasedTriggeringPolicy size="1GB"/>
      </policies>
      <DefaultRolloverStrategy max="9">
        <Delete basePath="${env:SCHEDULER_LOGS}">
          <IfFileName glob="*/${env:SCHEDULER_APPNAME}-*.log.gz" />
          <IfLastModified age="30d" />
        </Delete>
      </DefaultRolloverStrategy>
    </rollingRandomAccessFile>
  </appenders>
  <loggers>
    <logger name="akka.event.slf4j.Slf4jLogger" level="WARN"/>
    <root level="INFO">
      <appenderRef ref="console" level="INFO"/>
      <appenderRef ref="file" level="DEBUG"/>
    </root>
  </loggers>
</configuration>

Explanations:

  • To change the number of log files modify <DefaultRolloverStrategy max="9"> to some other value.
  • To change the log retention period modify <IfLastModified age="30d" /> to some other value.
  • To enable debug mode modify <root level="INFO"> to <root level="DEBUG"> or other.

JOC Cockpit log4j2 Configuration

JOC Cockpit log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
        <Properties>
                <Property name="TimeZone">{Etc/UTC}</Property>
                <Property name="RetainDays">30d</Property>
                <Property name="NumOfFilesPerDay">5</Property>
                <Property name="MaxSizePerFile">100MB</Property>

                <!--Configuration for loggers of the web services in joc.log
                        Possibly values are ERROR, WARN, INFO, DEBUG, TRACE
                        Default: INFO
                -->
                <Property name="RootLogLevel">info</Property>

                <!--Configuration for an extra database log file (database-debug.log) if necessary
                        OFF: without extra log
                        ERROR, WARN, INFO, DEBUG, TRACE: creates extra log with corresponding log level
                        SQL statement are included from DEBUG and their binding with TRACE
                -->
                <Property name="DatabaseLogLevel">off</Property>

                <!--Configuration for an extra shiro log file (shiro.log) if necessary
                        OFF: without extra log
                        ERROR, WARN, INFO, DEBUG, TRACE: creates extra log with corresponding log level
                        SQL statement are included from DEBUG and their binding with TRACE
                -->
                <Property name="AuthLogLevel">off</Property>
        </Properties>
        <Appenders>
                <!-- Appender for audit log -->
                <RollingFile name="AuditLogAppender"
                        fileName="${sys:user.dir}/logs/audit.log"
                        filePattern="${sys:user.dir}/logs/audit-%d{yyyy-MM}-%i.log.gz"
                        createOnDemand="true">
                        <PatternLayout
                                pattern="%d{ISO8601}${TimeZone} %-5p %m%throwable{short}%n"
                                charset="UTF-8"/>
                        <Policies>
                                <TimeBasedTriggeringPolicy/>
                                <SizeBasedTriggeringPolicy size="${MaxSizePerFile}"/>
                        </Policies>
                        <DefaultRolloverStrategy fileIndex="nomax"/>
                </RollingFile>

                <!-- Appender for connection pool log -->
                ...
        </Appenders>
        ...
<Configuration>

Explanations:

  • To change the number of log files modify <DefaultRolloverStrategy max="9"> to some other value.
  • To enable debug mode modify <root level="INFO"> to <root level="DEBUG">



  • No labels