<?xml version="1.0" encoding="UTF-8"?>

<!-- Configuration has an attribute named status that you can set to trace or debug to get configuration messages from Log4J2. -->
<Configuration>
	<Properties>
		<Property name="logDir">PPSLogs</Property>
		<Property name="maxFileSize">100 MB</Property>
		<Property name="maxRolloverFiles">10</Property>
 		<Property name="logPattern">%d{DEFAULT} %-5p [%t] [%c:%M] %m%n</Property>
	</Properties>

	<Appenders>
		<Console name="ConsoleAppender" target="SYSTEM_OUT">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
		</Console>
		
		<RollingFile name="PPSNAppender" fileName="${logDir}/ppsn.log" filePattern="${logDir}/ppsn-%i.log">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
			<Policies>
				<OnStartupTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy max="${maxRolloverFiles}"/>
		</RollingFile>

		<RollingFile name="HibernateAppender" fileName="${logDir}/hibernate.log" filePattern="${logDir}/hibernate-%i.log">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
			<Policies>
				<OnStartupTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy max="${maxRolloverFiles}"/>
		</RollingFile>

		<RollingFile name="SpringAppender" fileName="${logDir}/spring.log" filePattern="${logDir}/spring-%i.log">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
			<Policies>
				<OnStartupTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy max="${maxRolloverFiles}"/>
		</RollingFile>

	    <RollingFile name="VAAppender" fileName="${logDir}/other_va_software.log" filePattern="${logDir}/other_va_software-%i.log">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
			<Policies>
				<OnStartupTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy max="${maxRolloverFiles}"/>
	    </RollingFile>

		<RollingFile name="OtherAppender" filename="${logDir}/other.log" filePattern="${logDir}/other-%i.log">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
			<Policies>
				<OnStartupTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy max="${maxRolloverFiles}"/>
		</RollingFile>
	
		<RollingFile name="PPSNPerformanceAppender"  fileName="${logDir}/ppsPerformance.log" filePattern="${logDir}/ppsPerformance-%i.log">
			<PatternLayout>
				<Pattern>${logPattern}</Pattern>
			</PatternLayout>
			<Policies>
				<OnStartupTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="${maxFileSize}" />
			</Policies>
			<DefaultRolloverStrategy max="${maxRolloverFiles}"/>
		</RollingFile>
	</Appenders>
	<Loggers>
		<logger name="gov.va.med.pharmacy" level="debug" additivity="false" includeLocation="true">
			<AppenderRef ref="PPSNAppender" />
		</logger>

		<!--
		We set this logger to "warn" instead of "info" because KAAJEE and VistALink are a little
		too verbose at "info".
		-->
		<logger name="gov.va.med" level="warn" additivity="false">
			<AppenderRef ref="VAAppender" />
		</logger>

		<logger name="org.aspectj" level="info" additivity="false">
			<AppenderRef ref="SpringAppender" />
		</logger>

		<logger name="org.dbunit" level="info" additivity="false">
			<AppenderRef ref="PPSNAppender" />
		</logger>

		<logger name="org.hibernate" level="info" additivity="false">
			<AppenderRef ref="HibernateAppender" />
		</logger>

		<logger name="org.springframework" level="info" additivity="false">
			<AppenderRef ref="SpringAppender" />
		</logger>

		<logger name="net.sf.navigator" level="info" additivity="false">
			<AppenderRef ref="PPSNAppender" />
		</logger>

		<logger name="net.sf.ehcache" level="info" additivity="false">
			<AppenderRef ref="PPSNAppender" />
		</logger>

		<!-- Special performance metrics Loggers -->
		<!-- AOP-based -->
		<logger
			name="org.springframework.aop.interceptor.PerformanceMonitorInterceptor"
			level="trace"
			additivity="false">
			<appender-ref ref="PPSNPerformanceAppender" />
		</logger>
		<logger
			name="org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor"
			level="trace"
			additivity="false">
			<appender-ref ref="PPSNPerformanceAppender" />
		</logger>

		<Root level="info" additivity="true">
			<AppenderRef ref="ConsoleAppender"/>
			<AppenderRef ref="OtherAppender" />
		</Root>
	</Loggers>
</Configuration>