Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 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.

...

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 100MB 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 their individual log rotation strategy, see below examples explained.

Log File Retention

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

Users are free to modify the Log4j2 configuration to apply their individual log retention period, see below examples explained.

Configuration Files explained

...

Code Block
languagexml
titleController, Agent log4j2.xml
linenumberstrue
collapsetrue
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN" shutdownHook="disable">
  <appenders>
    <console name="console" target="SYSTEM_ERR"> <properties>
      <patternLayout pattern="%highlight{%d{EE HH:mm:ss.SSS} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message}{WARN=magenta}%n"/>          <property name="LogLevel">INFO</property>
    </console>
    <rollingRandomAccessFile name="file"
         <Property name="RetainDays">30d</Property>
                <Property    fileName="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}.log"name="MaxSizeOfRolledOverFiles">5GB</Property>
                <Property name="MaxSizePerFile">100MB</Property>
        </properties>

        filePattern="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}-%d{yyyy-MM-dd}-%i.log.gz"
<appenders>
                <console name="console" target="SYSTEM_ERR">
             immediateFlush="false">
      <patternLayout pattern="%d{yyyy-MM-dd     <patternLayout pattern="%highlight{%d{EE HH:mm:ss,SSSZ.SSS} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message%n"
%message}{WARN=magenta}%n"/>
                </console>

      charset="UTF-8"/>
      <policies>
    <rollingRandomAccessFile name="fileInfo"
   <onStartupTriggeringPolicy/>
        <timeBasedTriggeringPolicy/>
        <sizeBasedTriggeringPolicy size="1GB"/>
      </policies>
      <DefaultRolloverStrategy maxfileName="9">${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}.log"
        <Delete basePath="${env:SCHEDULER_LOGS}">
            <IfFileName glob="*            filePattern="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}-%d{yyyy-MM-dd}-*%i.log.gz" />
          <IfLastModified age="30d" />
        </Delete>
      </DefaultRolloverStrategy>
    </rollingRandomAccessFile>
  </appenders>
  <loggers>
    <logger name="akka.event.slf4j.Slf4jLogger" level="WARN"/>
immediateFlush="false">
         <root level="INFO">
      <appenderRef ref="console" level="INFO"/>
      <appenderRef<patternLayout refpattern="file" level="DEBUG"/>
%d{yyyy-MM-dd HH:mm:ss,SSSZ} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message%n"
            </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

                            charset="UTF-8"/>
                        <policies>
                                <onStartupTriggeringPolicy/>
                                <timeBasedTriggeringPolicy/>
                                <sizeBasedTriggeringPolicy size="${MaxSizePerFile}"/>
                        </policies>
                        <DefaultRolloverStrategy fileIndex="nomax">
                                <Delete basePath="${env:SCHEDULER_LOGS}">
                                        <IfFileName glob="*/${env:SCHEDULER_APPNAME}-*.log.gz" />
                                        <IfAny>
                                                <IfLastModified age="${RetainDays}" />
                                                <IfAccumulatedFileSize exceeds="${MaxSizeOfRolledOverFiles}"/>
                                        </IfAny>
                                </Delete>
                        </DefaultRolloverStrategy>
                </rollingRandomAccessFile>

                <rollingRandomAccessFile name="fileDebug"
                                fileName="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}-debug.log"
                                filePattern="${env:SCHEDULER_LOGS}/${env:SCHEDULER_APPNAME}-debug-%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="${MaxSizePerFile}"/>
                        </policies>
                        <DefaultRolloverStrategy fileIndex="nomax">
                                <Delete basePath="${env:SCHEDULER_LOGS}">
                                        <IfFileName glob="*/${env:SCHEDULER_APPNAME}-debug-*.log.gz" />
                                        <IfAny>
                                                <IfLastModified age="${RetainDays}" />
                                                <IfAccumulatedFileSize exceeds="${MaxSizeOfRolledOverFiles}"/>
                                        </IfAny>
                                </Delete>
                                        </IfAny>
                                </Delete>
                        </DefaultRolloverStrategy>
                </rollingRandomAccessFile>
        </appenders>

        <loggers>
                <!-- logger name="js7" level="debug"/ -->
                <logger name="spray" level="INFO"/>
                <logger name="akka" level="INFO"/>
                <logger name="akka.event.slf4j.Slf4jLogger" level="WARN"/>
                <logger name="js7.common.akkahttp.web.auth.GateKeeper" level="ERROR"/>
                <root level="INFO">
                        <!--appenderRef ref="console" level="ERROR"/-->
                        <appenderRef ref="fileInfo" level="INFO"/>
                        <appenderRef ref="fileDebug" level="${LogLevel}"/>
                </root>
        </loggers>
</configuration>

Explanations:

  • To modify the time zone that is applied to log entries and to the point in time of log rotation modify <Property name="TimeZone">{Etc/UTC}</Property>. The time zone is specified during installation.
  • To enable debug mode modify <property name="LogLevel">INFO</property> to DEBUG.
  • To change the log retention period modify <Property name="RetainDays">30d</Property> to some other value. Consider to use the suffix d(ays), w(eeks), m(onths).
  • To limit the max. size of an individual log file modify <Property name="MaxSizePerFile">100MB</Property> to some other value. Consider to use the units MB, GB.
  • To limit space consumption of all log files modify <Property name="MaxSizeOfRolledOverFiles">5GB</Property> to some other value. Consider to use the units MB, GB.

JOC Cockpit log4j2 Configuration

Code Block
languagexml
titleJOC Cockpit log4j2.xml
linenumberstrue
collapsetrue
<?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>
Code Block
languagexml
titleJOC Cockpit log4j2.xml
linenumberstrue
collapsetrue
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
        <Properties>
        <!--Configuration for loggers of the web services  <Property name="TimeZone">{Etc/UTC}</Property>
    in joc.log
            <Property name="RetainDays">30d</Property>
           Possibly values are ERROR,  <Property name="NumOfFilesPerDay">5</Property>
WARN, INFO, DEBUG, TRACE
                        <Property name="MaxSizePerFile">100MB</Property>

Default: INFO
                <!--Configuration>
 for loggers of the web services in joc.log
         <Property name="RootLogLevel">info</Property>

              Possibly values are ERROR, WARN, INFO, DEBUG, TRACE
    <!--Configuration for an extra database log file (database-debug.log) if necessary
                    Default: INFO
   OFF: without extra log
          -->
              ERROR, WARN, <Property name="RootLogLevel">info</Property>

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

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

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

                <SizeBasedTriggeringPolicy size="${MaxSizePerFile}"/>
     <!-- Appender for connection pool log -->
                   </Policies>...
            </Appenders>
            <DefaultRolloverStrategy fileIndex="nomax"/>
                </RollingFile>

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

Explanations:

...
<Configuration>

Explanations:

  • To modify the time zone that is applied to log entries and to the point in time of log rotation modify <Property name="TimeZone">{Etc/UTC}</Property>. The time zone is specified during installation.
  • To enable debug mode modify <property name="LogLevel">INFO</property> to DEBUG.
  • To change the log retention period modify <Property name="RetainDays">30d</Property> to some other value. Consider to use the suffix d(ays), w(eeks), m(onths).
  • To limit the max. size of an individual log file modify <Property name="MaxSizePerFile">100MB</Property> to some other value. Consider to use the units MB, GB.
  • To limit space consumption of all log files modify <Property name="MaxSizeOfRolledOverFiles">5GB</Property> to some other value. Consider to use the units MB, GB.
  • 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">