<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="5" packages="com.hof.util.logging.log4j2">

	<Properties>
		<Property name="appenderPatternLayout">YF:%d{yyyy-MM-dd HH:mm:ss.SSS}:%5p (%c{1}) - %m%n</Property>
		<Property name="appenderPatternLayoutEmail">%d{yyyy-MM-dd HH:mm:ss.SSS} %5p: %m%n</Property>
		<Property name="appenderPatternLayoutJDBC">%d{yyyy-MM-dd HH:mm:ss.SSS} %6p: %m%n</Property>
		<Property name="logDir">${sys:catalina.home}/logs</Property>
		<Property name="maxFileSize">1024 KB</Property>
		<Property name="maxFiles">9</Property>
	</Properties>

	<Appenders>
		<Console name="cons" target="SYSTEM_OUT">
			<PatternLayout pattern="${appenderPatternLayout}" />
		</Console>

		<!-- 
		application log file logging
		This is a rolling log file. When the log file reaches 100MB it is compressed and archived,
		and a new log file is started. The 9 most recent log files are kept.
		 -->
		<RollingFile name="applog" fileName="${logDir}/yellowfin.log" filePattern="${logDir}/yellowfin.log.%i">
			<PatternLayout pattern="${appenderPatternLayout}" />			
			<Policies>
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy fileIndex="min" max="${maxFiles}"/>
		</RollingFile>
		
		<!-- 		
		Connection pooling has special logging facilities. We set up two appenders
		here to handle them.
		   jdbclog - a standard appender that will receive log messages for the configuration db
		   sourcelog - uses the SourceLogAppender to write log messages to separate files
		               for each data source
		-->
		<RollingFile name="jdbclog" fileName="${logDir}/jdbc.log" filePattern="${logDir}/jdbc.log.%i">
			<PatternLayout pattern="${appenderPatternLayoutJDBC}" />			
			<Policies>
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy fileIndex="min" max="${maxFiles}"/>
		</RollingFile>
		<SourceLog name="sourcelog" fileName="${logDir}/source.%s.log" filePattern="${logDir}/source.%s.log.%i"
		           maxFileSize="${maxFileSize}" maxFiles="${maxFiles}">
			<PatternLayout pattern="${appenderPatternLayoutJDBC}" />			
		</SourceLog>
		
		<!-- Email logging also has a special logging facility. We set up an appender to log to a separate file. -->		
		<RollingFile name="emaillog" fileName="${logDir}/email.log" filePattern="${logDir}/email.log.%i">
			<PatternLayout pattern="${appenderPatternLayoutEmail}" />			
			<Policies>
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy fileIndex="min" max="${maxFiles}"/>
		</RollingFile>
		
		<!-- Data Transformation logs go to a separate file -->
		<RollingFile name="etllog" fileName="${logDir}/transformations.log" filePattern="${logDir}/transformations.log.%i">
			<PatternLayout pattern="${appenderPatternLayout}" />			
			<Policies>
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy fileIndex="min" max="${maxFiles}"/>
		</RollingFile>
		
	</Appenders>


	<Loggers>
		<!-- Set the default logging level to INFO, and log to console and application  log file -->
		<Root level="INFO">
			<AppenderRef ref="applog"/>
			<AppenderRef ref="cons" />
		</Root>

		<!-- uncomment to set everything under com.hof and bi.yellowfin to debug -->
		<!--
		<Logger name="com.hof" level="DEBUG" />
		<Logger name="bi.yellowfin" level="DEBUG" />
 		-->
 		
 		<Logger name="com.hof.pool.DBConnectionPool.jdbclog" additivity="false" level="INFO">
			<AppenderRef ref="jdbclog" />
		</Logger>
 		<Logger name="com.hof.pool.DBConnectionPool.sourcelog" additivity="false" level="INFO">
			<AppenderRef ref="sourcelog" />
		</Logger> 		
 		<Logger name="com.hof.util.Email.emaillog" additivity="false" level="INFO">
			<AppenderRef ref="emaillog" />
		</Logger>
 		<Logger name="com.hof.mi.etl" additivity="false" level="INFO">
 			<AppenderRef ref="etllog" />
		</Logger>
 		
	</Loggers>
</Configuration>
