You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 12
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:
| Windows | Unix |
---|
Controller | C:\Program Files\sos-berlin.com\js7\controller\lib\log42j.xml | /opt/sos-berlin.com/js7/controller/lib/log4j2,xml |
---|
Agent | C:\Program Files\sos-berlin.com\js7\agent\lib\log42j.xml | /opt/sos-berlin.com/js7/agent/lib/log4j2,xml |
---|
JOC Cockpit | C:\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 single 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 Retention
By default the log retention period for any log files is 30 days, i.e. log files older than this will be removed.
This does not apply to the audit.log
log file that is rotated but is not subject to log retention and therefore is not removed.
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
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" shutdownHook="disable">
<Properties>
<Property name="TimeZone">${env:SCHEDULER_TZ:-Etc/UTC}</Property>
<Property name="LogDir">${env:SCHEDULER_LOGS:-logs}</Property>
<Property name="LogBasename">${env:SCHEDULER_APPNAME:-controller}</Property>
<Property name="RetainDays">30d</Property>
<Property name="MaxSizeOfRolledOverFiles">5GB</Property>
<Property name="MaxSizePerFile">100MB</Property>
<!-- Log level of the Root Logger. -->
<Property name="RootLogLevel">INFO</Property>
<!-- Configuration for a 2nd debug log file (OFF|DEBUG|TRACE)
If this value is set to DEBUG or TRACE then the above
RootLogLevel has to have the same value.
-->
<Property name="LogLevelOfDebugLog">OFF</Property>
</Properties>
<Appenders>
<Console name="console" target="SYSTEM_ERR">
<PatternLayout pattern="%highlight{%d{EE HH:mm:ss.SSS}{${TimeZone}} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message}{WARN=magenta}%n"/>
</Console>
<RollingRandomAccessFile name="fileInfo"
fileName="${LogDir}/${LogBasename}.log"
filePattern="${LogDir}/${LogBasename}-%d{yyyy-MM-dd}-%i.log.gz"
immediateFlush="false">
<PatternLayout pattern="%d{ISO8601}{${TimeZone}} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message%n"
charset="UTF-8"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="${MaxSizePerFile}"/>
</Policies>
<DefaultRolloverStrategy fileIndex="nomax">
<Delete basePath="${LogDir}">
<IfFileName glob="*/${LogBasename}-*.log.gz" />
<IfAny>
<IfLastModified age="${RetainDays}" />
<IfAccumulatedFileSize exceeds="${MaxSizeOfRolledOverFiles}"/>
</IfAny>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
<RollingRandomAccessFile name="fileDebug"
fileName="${LogDir}/${LogBasename}-debug.log"
filePattern="${LogDir}/${LogBasename}-debug-%d{yyyy-MM-dd}-%i.log.gz"
immediateFlush="false">
<PatternLayout pattern="%d{ISO8601}{${TimeZone}} %-5level{INFO=info, DEBUG=debug, TRACE=trace} %logger - %message%n"
charset="UTF-8"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="${MaxSizePerFile}"/>
</Policies>
<DefaultRolloverStrategy fileIndex="nomax">
<Delete basePath="${LogDir}">
<IfFileName glob="*/${LogBasename}-*.log.gz" />
<IfAny>
<IfLastModified age="${RetainDays}" />
<IfAccumulatedFileSize exceeds="${MaxSizeOfRolledOverFiles}"/>
</IfAny>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<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="${RootLogLevel}">
<!--AppenderRef ref="console" level="ERROR"/-->
<AppenderRef ref="fileInfo" level="INFO"/>
<AppenderRef ref="fileDebug" level="${LogLevelOfDebugLog}"/>
</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 the startscript by setting the environment variable SCHEDULER_TZ
. - To enable debug mode modify
<property name="RootLogLevel">INFO</property>
and <property name="LogLevelOfDebugLog">OFF</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
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="TimeZone">Etc/UTC</Property>
<Property name="RetainDays">30d</Property>
<Property name="MaxSizeOfRolledOverFiles">5 GB</Property>
<Property name="MaxSizePerFile">100 MB</Property>
<!-- Log level of the Root Logger. -->
<Property name="RootLogLevel">INFO</Property>
<!-- Configurations for 2nd debug log files (OFF|DEBUG|TRACE)
If one of these values is set to DEBUG or TRACE then the above
RootLogLevel has to have the same value.
-->
<Property name="JocLogLevel">OFF</Property>
<Property name="ClusterLogLevel">OFF</Property>
<Property name="HistoryLogLevel">OFF</Property>
<Property name="DailyPlanLogLevel">OFF</Property>
<Property name="CleanupLogLevel">OFF</Property>
<Property name="AuthLogLevel">OFF</Property>
<Property name="ConnectionPoolLogLevel">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 -->
...
</Appender>
</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 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 space consumption of all log files modify
<Property name="MaxSizeOfRolledOverFiles">5 GB</Property>
to some other value. Consider to use the units MB
, GB
. - To limit the max. size of individual log files modify
<Property name="MaxSizePerFile">100 MB</Property>
to some other value. Consider to use the units MB
, GB
. - To enable debug mode modify
<property name="RootLogLevel">INFO</property>
to DEBUG
. In addition modify the value of one or more of the following properties accordingly to enable debug output with the respective debug log file:
Log File | Property |
|
---|
joc-debug.log | <Property name="JocLogLevel">DEBUG</Property> |
|
service-cluster-debug.log | <Property name="ClusterLogLevel">DEBUG</Property> |
|
service-history-debug.log | <Property name="HistoryLogLevel">DEBUG</Property> |
|
service-dailyplan-debug.log | <Property name="DailyPlanLogLevel">DEBUG</Property> |
|
service-cleanup-debug.log | <Property name="CleanupLogLevel">DEBUG</Property> |
|
authentication-debug.log | <Property name="AuthLogLevel">DEBUG</Property> |
|
connection-pool-debug.log | <Property name="ConnectionPoolLogLevel">DEBUG</Property> |
|