<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
    <!-- Set the above debug attribute to true to see logback status information. -->

    <!-- The encoder uses a default class.  This can be changed using the class attribute -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <!-- The log output format. UNIQUE_ID is a custom MDC variable passed from
                 the APIM down through the loadbalancer and proxy to the container.
                 It provides end to end request tracking.  A random string will be
                 generated by the servlet filter or thread initialization code when
                 one is not available in the http request header. 
                 See AloeLoggingFilter for details. -->
            <Pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread/%X{UNIQUE_ID}] %class{36}:%line - %msg%n</Pattern>
        </encoder>
    </appender>

    <!-- Rollover to a new log file on a monthly basis, set a limits to manage sizes, 
         default output to the user's home directory. -->
	<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${aloe.log.directory:-${user.home}}/${aloe.log.file:-aloe-job.log}</file>
		<rollingPolicy
			class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<!-- Rollover monthly, incorporate size-triggered sequence number. -->
			<fileNamePattern>${aloe.log.directory:-${user.home}}/${aloe.log.file}-%d{yyyy-MM}.%i.log</fileNamePattern>
			<!-- Each file should be at most 500MB, keep 6 months worth of history, 
				 but at most a total of 10GB across all log files. -->
			<maxFileSize>500MB</maxFileSize>
			<maxHistory>6</maxHistory>
			<totalSizeCap>10GB</totalSizeCap>
		</rollingPolicy>
		<encoder>
		    <!-- See console pattern for description. -->
            <Pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread/%X{UNIQUE_ID}] %class{36}:%line - %msg%n</Pattern>
		</encoder>
	</appender>
  
    <!-- Root logger's appenders are inherited by other loggers by default -->
    <root level="DEBUG">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>

    <!-- Set additivity attribute to false to not inherit ancestor appenders. -->
    <logger name="edu.utexas.tacc.aloe" level="TRACE"/>
    
    <!-- Control library logging. -->
    <logger name="com.zaxxer.hikari" level="ERROR"/>
</configuration>
