Logging Behavior
Write to Disk Logging Behavior Environment Variables describes the variables that control aspects of Write to Disk log4j2 CDR logging such as the file path, name, and rollover behavior.
Variable | Description | Default |
---|---|---|
CDR_MTX_LOGGER_NAME | The name of the logger as identified in the log4j2 configuration. If this name is changed, the gateway.external.kafka.logger.name
property in nf.yaml must be set to the same value. |
networkcdr |
CDR_MTX_LOG_DIR | The local path to the log file. | /var/events/records |
CDR_MTX_LOG_FILENAME | The name of the log file. | mtx-sba-cdr.log |
CDR_FILE_LOG_SIZE | The size at which log files are rotated. | 200MB |
CDR_FILE_LOG_MAX | The maximum number of log files to retain. The default setting ensures no records are deleted by rollover behavior. This can be set to a lower value to prevent disk space from running out. | 999 |
CDR_FILE_LOG_PLACES | Number of zero-padded places for numbering in the names of rollover files. The default value of 3 matches the max default of 999 retained files. | 3 |
Default settings write records to the local path /var/events/records/mtx-sba-cdr.log. The log file is rolled over based on size. By default, the log file rolls ove when
it reaches 200 MB. The file then rolls over and a compressed file named: /var/events/records/mtx-sba-cdr.log-2024-08-01-001.gz
is created from it. The filename has the
following sections:
/var/events/records/mtx-sba-cdr.log-2024-08-01-08-00001.gz
|------- A --------|------ B ------|----- C -----|- D -|
In the filename:
- A — The local path to the file, as specified in
CDR_MTX_LOG_DIR
. - B — The filename, as specified in
CDR_MTX_LOG_FILENAME
. - C — The rollover date, fixed at
yyyy-MM-dd-HH
. - D — The index with zero-padding up to the number of places specified in
CDR_FILE_LOG_PLACES
.
The default values, with CDR_FILE_LOG_MAX set to 99999, prevent deletion of log files containing records. Setting a lower value for CDR_FILE_LOG_MAX
can be used to prevent
disk space from running out.
CDR_FILE_LOG_MAX
can cause log files to be deleted.
This can help to prevent disk space from running out which can lead to new records being lost. The CDR_FILE_LOG_MAX
variable determines the maximum index value for log
files that have the same name excluding the index. For example, setting CDR_FILE_LOG_MAX
to 3 means that only 3 compressed files are kept per hour, given the date pattern
yyyy-MM-dd-HH
. The next time the log file is rolled, it takes the place of the last file and all previous files are renamed to take the previous position. This
behavior only affects files that share the same name, excluding the index, so the behavior resets in the next hour.The following is the default log4j2 configuration:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" strict="true" name="XMLConfig"
packages="org.apache.logging.log4j.test">
<Properties>
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xEx</Property>
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
<Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd HH:mm:ss.SSS</Property>
<Property name="CONSOLE_LOG_PATTERN">%d{${LOG_DATEFORMAT_PATTERN}} | ${LOG_LEVEL_PATTERN} | %equals{%X{requestId}}{}{%X{sessionId}} | %t | %c | %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD:-${env:LOG_EXCEPTION_CONVERSION_WORD}}</Property>
<Property name="FILE_LOG_PATTERN">%d{${LOG_DATEFORMAT_PATTERN}} | ${LOG_LEVEL_PATTERN} | %equals{%X{requestId}}{}{%X{sessionId}} | %t | %c | %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD:-${env:LOG_EXCEPTION_CONVERSION_WORD}}</Property>
<Property name="LOG_FILE_PATH">${sys:MTX_LOG_DIR:-${env:MTX_LOG_DIR:-/var/log/mtx}}</Property>
<Property name="LOG_FILE_NAME">${sys:MTX_LOG_FILENAME:-${env:MTX_LOG_FILENAME:-nf.log}}</Property>
<Property name="FILE_LOG_SIZE">${sys:FILE_LOG_SIZE:-${env:FILE_LOG_SIZE:-20 MB}}</Property>
<Property name="FILE_LOG_MAX">${sys:FILE_LOG_MAX:-${env:FILE_LOG_MAX:-10}}</Property>
<!-- Network CDR logger configuration -->
<Property name="CDR_LOGGER">${sys:CDR_MTX_LOGGER_NAME:-${env:CDR_MTX_LOGGER_NAME:-networkcdr}}</Property>
<Property name="CDR_FILE_LOG_PATTERN">%m%n%xEx</Property>
<Property name="CDR_LOG_FILE_PATH">${sys:CDR_MTX_LOG_DIR:-${env:CDR_MTX_LOG_DIR:-/var/events/records}}</Property>
<Property name="CDR_LOG_FILE_NAME">${sys:CDR_MTX_LOG_FILENAME:-${env:CDR_MTX_LOG_FILENAME:-mtx-sba-cdr.log}}</Property>
<Property name="CDR_FILE_LOG_SIZE">${sys:CDR_FILE_LOG_SIZE:-${env:CDR_FILE_LOG_SIZE:-200MB}}</Property>
<Property name="CDR_FILE_LOG_MAX">${sys:CDR_FILE_LOG_MAX:-${env:CDR_FILE_LOG_MAX:-999}}</Property>
<Property name="CDR_FILE_NUM_PLACES">${sys:CDR_FILE_LOG_PLACES:-${env:CDR_FILE_LOG_PLACES:-3}}</Property>
</Properties>
<Appenders>
<Appender type="Console" name="Console">
<PatternLayout>
<pattern>${sys:CONSOLE_LOG_PATTERN:-${env:CONSOLE_LOG_PATTERN}}</pattern>
<disableAnsi>${sys:MTX_NO_COLORS:-${env:MTX_NO_COLORS:-false}}</disableAnsi>
</PatternLayout>
</Appender>
<RollingFile name="File-Appender" fileName="${LOG_FILE_PATH}/${LOG_FILE_NAME}"
filePattern="${LOG_FILE_PATH}/${LOG_FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz" createOnDemand="true" >
<PatternLayout>
<Pattern>${sys:FILE_LOG_PATTERN:-${env:FILE_LOG_PATTERN}}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="${FILE_LOG_SIZE}" />
</Policies>
<DefaultRolloverStrategy max="${FILE_LOG_MAX}" />
</RollingFile>
<!-- CDR LOGGING APPENDER -->
<RollingFile name="Cdr-Appender"
fileName="${CDR_LOG_FILE_PATH}/${CDR_LOG_FILE_NAME}"
filePattern="${CDR_LOG_FILE_PATH}/${CDR_LOG_FILE_NAME}-%d{yyyy-MM-dd-HH}-%0${CDR_FILE_NUM_PLACES}i.gz"
createOnDemand="true" >
<PatternLayout>
<pattern>${sys:CDR_FILE_LOG_PATTERN:-${env:CDR_FILE_LOG_PATTERN}}</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="${CDR_FILE_LOG_SIZE}"/>
</Policies>
<DefaultRolloverStrategy max="${CDR_FILE_LOG_MAX}" />
</RollingFile>
<!-- Choose which Appender to use based on the MTX_LOG_MECHANISM environment variable (defaults to FILE) -->
<Routing name="LogMechanismRouter">
<Routes pattern="$${sys:MTX_LOG_MECHANISM:-${env:MTX_LOG_MECHANISM:-FILE}}">
<Route ref="File-Appender" key="FILE" />
<Route ref="Console" key="STDOUT" />
</Routes>
</Routing>
</Appenders>
<Loggers>
<Logger name="${CDR_LOGGER}" level="info" additivity="false">
<AppenderRef ref="Cdr-Appender"/>
</Logger>
<Logger name="com.matrixx" level="info" />
<Logger name="com.matrixx.sba" level="${sys:MTX_SBA_LOG_LEVEL:-${env:MTX_SBA_LOG_LEVEL:-info}}"/>
<Logger name="com.matrixx.cdr" level="${sys:MTX_CDR_LOG_LEVEL:-${env:MTX_CDR_LOG_LEVEL:-info}}"/>
<Logger name="com.matrixx.yaml" level="${sys:MTX_SBA_LOG_LEVEL:-${env:MTX_SBA_LOG_LEVEL:-info}}"/>
<Logger name="com.matrixx.mapping" level="${sys:MTX_SBA_DMM_LOG_LEVEL:-${env:MTX_SBA_DMM_LOG_LEVEL:-info}}" />
<Logger name="com.matrixx.labs.nettymdc" level="${sys:MTX_SBA_LOG_LEVEL:-${env:MTX_SBA_LOG_LEVEL:-info}}" />
<!-- for the mock groovy scripts -->
<Logger name="mocks" level="${sys:MTX_SBA_LOG_LEVEL:-${env:MTX_SBA_LOG_LEVEL:-info}}" />
<Logger name="io.swagger" level="info" />
<!-- Set the following to warn by default otherwise it logs every http request as INFO -->
<Logger name="io.vertx.ext.web.handler.impl.LoggerHandlerImpl" level="${sys:MTX_SBA_LOG_VERBOSE:-${env:MTX_SBA_LOG_VERBOSE:-warn}}"/>
<Logger name="io.vertx" level="${sys:MTX_SBA_LOG_VERBOSE:-${env:MTX_SBA_LOG_VERBOSE:-info}}"/>
<Logger name="io.netty" level="${sys:MTX_SBA_LOG_VERBOSE:-${env:MTX_SBA_LOG_VERBOSE:-info}}"/>
<Logger name="io.opentelemetry" level="warn"/>
<!-- Apache Kafka -->
<Logger name="org.apache.kafka" level="${sys:MTX_SBA_KAFKA_LOG_LEVEL:-${env:MTX_SBA_KAFKA_LOG_LEVEL:-warn}}" />
<Root level="info">
<AppenderRef ref="LogMechanismRouter"/>
</Root>
</Loggers>
</Configuration>