All Downloads are FREE. Search and download functionalities are using the official Maven repository.

j2-rolling-config.0.0.8.OSS.source-code.log4j2-spring.xml Maven / Gradle / Ivy

<?xml version="1.0" encoding="UTF-8"?>
<!--
-->
<Configuration status="WARN">
    <Properties>
        <!-- default log file name -->
        <!-- Priority: INSTANCE_NAME (from docker), ${hostname} (from log4j2) -->
        <Property name="defaultLoggingFile">${env:INSTANCE_NAME:-${hostName}}</Property>
        <Property name="loggingFileFromEnv">${env:LOG_FILE}</Property>
        <Property name="loggingFile">${loggingFileFromEnv:-${defaultLoggingFile}}</Property>

        <!-- default log directory name -->
        <Property name="applicationName">${env:SPRING_APPLICATION_NAME:-application}</Property>
        <Property name="defaultLoggingPath">${sys:user.dir}/data/logs/${applicationName}</Property>
        <Property name="loggingPath">${env:LOG_PATH:-${defaultLoggingPath}}</Property>
    </Properties>

    <Appenders>
        <Console name="STDOUT">
            <PatternLayout charset="UTF-8" >
                <pattern>%d{ISO8601}{GMT+8} %highlight{%p} %style{%c{1.} [%t] %m}{bold,green}%n</pattern>
            </PatternLayout>
        </Console>
        <RollingRandomAccessFile
                name="ROLLING_FILE"
                fileName="${loggingPath}/${loggingFile}.log"
                filePattern="${loggingPath}/$${date:yyyy-MM}/${loggingFile}-%d{yyyy-MM-dd}-%i.log"
                immediateFlush="true" append="true" bufferSize="524288"
        >
            <PatternLayout charset="UTF-8" >
                <Pattern>%d{ISO8601}{GMT+8} %p %c{1.} [%t] %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <OnStartupTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="512 MB"/>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy>
                <Delete basePath="${loggingPath}" maxDepth="2">
                    <IfFileName glob="*/${loggingFile}-*.log">
                        <IfLastModified age="1d">
                            <IfAny>
                                <IfAccumulatedFileSize exceeds="2 GB"/>
                            </IfAny>
                        </IfLastModified>
                    </IfFileName>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <!-- level="${env:LOGGING_LEVEL_ROOT:-DEBUG}" on logger here will override spring-boot's logging.level.${loggerName}: ${logLevel} -->
        <Root includeLocation="false">
            <AppenderRef ref="ROLLING_FILE"/>
            <AppenderRef ref="STDOUT"/>
        </Root>
    </Loggers>
</Configuration>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy