<?xml version="1.0" encoding="UTF-8"?>
<!-- https://logging.apache.org/log4j/2.x/manual/configuration.html -->
<!-- This is a Log4j 2 configuration file _template_. Find and replace every occurrence of CHANGE_ME. -->
<Configuration xmlns:xi="http://www.w3.org/2001/XInclude" monitorInterval="10" status="DEBUG" >
    <!-- The Configuration can reference its properties directly. -->
    <!-- Properties also provide default values when Log4j 2 Lookups fail (e.g. if an ${env:VAR} is not set) -->
    <Properties>
        <!-- PULSAR_APP_NAME is also your Apache Kafka topic name. -->
        <Property name="PULSAR_APP_NAME">ace</Property>
        <Property name="PULSAR_LOG_DIR">/pulsar-logs-root/${env:MESOS_TASK_ID}</Property>
        <Property name="MESOS_TASK_ID">unknown-task.${env:PULSAR_APP_NAME}.${date:yyyyMMddHHmmssSSS}</Property>
    </Properties>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
        <!-- This RollingFile Appender writes log files that conform to the -->
        <!-- Service Engine logging protocol: -->
        <!-- https://gsd.akamai.com/wiki/display/SET/Logging#Logging-LoggingProtocol -->
        <!-- Do not change RollingFile attributes! -->
        <RollingRandomAccessFile name="RollingFileJson" immediateFlush="false"
                     fileName="${env:PULSAR_LOG_DIR}/${env:PULSAR_APP_NAME}.jsonl"
                     filePattern="${env:PULSAR_LOG_DIR}/${env:PULSAR_APP_NAME}-%d{yyyyMMddHHmm}.%i.jsonl">
            <!-- Do not change Policies! -->
            <Policies>
                <!-- Roll if the log file is older than the JVM's start time. -->
                <OnStartupTriggeringPolicy/>
                <!-- Roll when the log file reaches the specified size. -->
                <SizeBasedTriggeringPolicy size="10MB"/>
                <!-- Roll when the date/time pattern no longer applies to the active file. -->
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <!-- Do not change DefaultRolloverStrategy!-->
            <!-- If fileIndex="max" (the default), a higher index is newer. -->
            <!-- Service Engine logging infrastructure requires the default behavior. -->
            <!--  -->
            <!-- Otherwise Log4j2 uses a Fixed Window strategy-within a period, max log files are kept; -->
            <!-- others are deleted after rolling, oldest first.-->
            <!-- This requires $windowSize rename operations,-->
            <!-- breaking Service Engine logging infrastructure -->
            <!--  -->
            <!-- A large max value prevents deletes and renames.-->
            <!-- If the filePattern is yyyyMMddHHmm (i.e. "minute" files) and size is 10MB,-->
            <!-- deletes and renames occur iff 100GB of log messages are written in one minute. -->
            <JsonTemplateLayout eventTemplateUri="classpath:log4j2JSONLayout.json"/>
            <DefaultRolloverStrategy max="10000"/>
            

        </RollingRandomAccessFile>

<!--        <Console name="ConsoleJson" target="SYSTEM_OUT">-->
<!--             <JsonTemplateLayout eventTemplateUri="classpath:log4j2JSONLayout.json"/>-->
<!--        </Console>-->

        <RollingRandomAccessFile name="RollingFileMetrics"
                     fileName="${env:PULSAR_LOG_DIR}/${env:PULSAR_APP_NAME}-metrics.jsonl"
                     filePattern="${env:PULSAR_LOG_DIR}/${env:PULSAR_APP_NAME}-metrics-%d{yyyyMMddHHmm}.%i.jsonl">
            <!-- Do not change Policies or the DefaultRolloverStrategy (explained above)! -->
            <Policies>
                <OnStartupTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10MB"/>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy max="10000"/>
            <!-- The Metrics reporter writes JSON Lines at the info log level. -->
            <PatternLayout pattern="%msg%n"/>
        </RollingRandomAccessFile>

        <RollingFile name="RollingFileHealth"
                     fileName="${env:PULSAR_LOG_DIR}/${env:PULSAR_APP_NAME}-health.jsonl"
                     filePattern="${env:PULSAR_LOG_DIR}/${env:PULSAR_APP_NAME}-health-%d{yyyyMMddHHmm}.%i.jsonl">
            <!-- Do not change Policies or the DefaultRolloverStrategy (explained above)! -->
            <Policies>
                <OnStartupTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10MB"/>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy max="10000"/>
            <!-- The HealthCheck reporter writes JSON Lines at the info log level. -->
            <PatternLayout pattern="%msg%n"/>
        </RollingFile>
        <RollingRandomAccessFile name="RollingFileTraces"
                     fileName="${env:PULSAR_LOG_DIR}/zipkin.jsonl"
                     filePattern="${env:PULSAR_LOG_DIR}/zipkin-%d{yyyyMMddHHmm}.%i.jsonl">
            <!-- Do not change Policies or the DefaultRolloverStrategy (explained above)! -->
            <Policies>
                <OnStartupTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10MB"/>
                <TimeBasedTriggeringPolicy/>
            </Policies>
            <DefaultRolloverStrategy max="10000"/>
            <!-- The Traces reporter writes JSON Lines at the info log level. -->
            <PatternLayout pattern="%msg%n"/>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="error">
            <AppenderRef ref="RollingFileJson"/>
            <AppenderRef ref="Console" />
        </Root>
        <!-- Use this appender and no other for Metrics reports. -->
        <Logger name="metrics" level="info" additivity="false">
            <AppenderRef ref="RollingFileMetrics"/>
        </Logger>
        <!-- Use this appender and no other for HealthCheck reports. -->
        <Logger name="health" level="info" additivity="false">
            <AppenderRef ref="RollingFileHealth"/>
        </Logger>
        <!-- Tweak logger levels here. -->
        <!-- Changes take effect within monitorInterval seconds. -->
        <Logger name="com.akamai.portal.ace" level="debug"/>
        <Logger name="com.akamai.ids" level="warn"/>
        <Logger name="org.apache.dbcp" level="debug"/>
        <Logger name="org.apache.commons.dbcp2" level="debug"/>
        <Logger name="com.akamai.provisioning.metrics.PtkTimer" level="info"/>
        <Logger name="com.akamai.portal.ace.dao.ActivationDAO" level="trace" />
    </Loggers>
</Configuration>
