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

Compare with Current View Page History

« Previous Version 5 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.
  • 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 as per JS7 component:


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


Changes to the Log4j2 configuration are applied within 60s and do not require the JS7 component to be restarted.

Log Rotation Strategy

By default log files are rotated on the following events:

  • if the size of a log file exceeds 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 to apply 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

Controller and Agent Log4j2 Configuration

Controller, Agent log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN" shutdownHook="disable">
        <properties>
                <property name="LogLevel">INFO</property>
                <Property name="RetainDays">30d</Property>
                <Property name="MaxSizeOfRolledOverFiles">5GB</Property>
                <Property name="MaxSizePerFile">100MB</Property>
        </properties>

        <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="fileInfo"
                                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="${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 individual log files 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

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 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 individual log files 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.


  • No labels