<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<conversionRule conversionWord="logger" converterClass="com.lee.LoggingConverter" />
<property scope="context" name="varName" value="varValue" />
<if condition='!isDefined("DEV")'>
<!-- local dev env -->
<then>
<appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5level %logger{80} - %msg %n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <prudent>true</prudent> -->
<file>\${user.home}/logs/hk_retail_out.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_out.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>2MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="PERFORMANCE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${user.home}/logs/hk_retail_perform.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_perform.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="METHOD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${user.home}/logs/hk_retail_method.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_method.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<encoder>
<!-- <pattern>%date [%X{flow}] %-5level %X{ip} %X{method} - %msg%n</pattern> -->
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="SQL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${user.home}/logs/hk_retail_sql.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_sql.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<encoder>
<!-- <pattern>%date [%X{flow}] %-5level %X{ip} %X{method} - %msg%n</pattern> -->
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.lee" level="debug" />
<logger name="PerformanceCounter">
<appender-ref ref="PERFORMANCE"/>
</logger>
<logger name="MethodLogging" level="debug">
<appender-ref ref="METHOD"/>
</logger>
<logger name="org.lee.mapper" level="debug">
<appender-ref ref="SQL"/>
</logger>
<root level="info">
<appender-ref ref="CON" />
<appender-ref ref="FILE" />
</root>
</then>
<else>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_out.%d{yyyy-MM-dd}${log.suffix}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="PERFORMANCE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_perform.%d{yyyy-MM}${log.suffix}.log</fileNamePattern>
<maxHistory>6</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="METHOD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_method.%d{yyyy-MM}${log.suffix}.log</fileNamePattern>
<maxHistory>6</maxHistory>
</rollingPolicy>
<encoder>
<!-- <pattern>%date [%X{flow}] %-5level %X{ip} %X{method} - %msg%n</pattern> -->
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="SQL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_sql.%d{yyyy-MM}${log.suffix}.log</fileNamePattern>
<maxHistory>6</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_error.%d{yyyy-MM-dd}${log.suffix}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date %-4relative [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<smtpHost>mailhost.jp.fid-intl.com</smtpHost>
<to>xxx@xxx.com</to>
<from>xxx@xxx.com</from>
<subject>[${API_ENV}][%-5level][HK-API${log.mail.subject.suffix}] %logger{80}</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date %-5level %logger{80}.%M - %message%n</pattern>
</layout>
</appender>
<logger name="com.lee" level="debug" />
<logger name="PerformanceCounter" additivity="false">
<appender-ref ref="PERFORMANCE"/>
</logger>
<logger name="MethodLogging">
<appender-ref ref="METHOD"/>
</logger>
<logger name="com.lee.mapper" additivity="false">
<appender-ref ref="SQL"/>
</logger>
<root level="info">
<appender-ref ref="FILE" />
<appender-ref ref="EMAIL" />
<appender-ref ref="ERROR" />
</root>
</else>
</if>
<configuration>
<conversionRule conversionWord="logger" converterClass="com.lee.LoggingConverter" />
<property scope="context" name="varName" value="varValue" />
<if condition='!isDefined("DEV")'>
<!-- local dev env -->
<then>
<appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5level %logger{80} - %msg %n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <prudent>true</prudent> -->
<file>\${user.home}/logs/hk_retail_out.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_out.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>2MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="PERFORMANCE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${user.home}/logs/hk_retail_perform.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_perform.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="METHOD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${user.home}/logs/hk_retail_method.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_method.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<encoder>
<!-- <pattern>%date [%X{flow}] %-5level %X{ip} %X{method} - %msg%n</pattern> -->
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="SQL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>\${user.home}/logs/hk_retail_sql.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>\${user.home}/logs/hk_retail_sql.log.%i.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<encoder>
<!-- <pattern>%date [%X{flow}] %-5level %X{ip} %X{method} - %msg%n</pattern> -->
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.lee" level="debug" />
<logger name="PerformanceCounter">
<appender-ref ref="PERFORMANCE"/>
</logger>
<logger name="MethodLogging" level="debug">
<appender-ref ref="METHOD"/>
</logger>
<logger name="org.lee.mapper" level="debug">
<appender-ref ref="SQL"/>
</logger>
<root level="info">
<appender-ref ref="CON" />
<appender-ref ref="FILE" />
</root>
</then>
<else>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_out.%d{yyyy-MM-dd}${log.suffix}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="PERFORMANCE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_perform.%d{yyyy-MM}${log.suffix}.log</fileNamePattern>
<maxHistory>6</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="METHOD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_method.%d{yyyy-MM}${log.suffix}.log</fileNamePattern>
<maxHistory>6</maxHistory>
</rollingPolicy>
<encoder>
<!-- <pattern>%date [%X{flow}] %-5level %X{ip} %X{method} - %msg%n</pattern> -->
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="SQL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_sql.%d{yyyy-MM}${log.suffix}.log</fileNamePattern>
<maxHistory>6</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>\${user.dir}/logs/server1/hk_retail_error.%d{yyyy-MM-dd}${log.suffix}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date %-4relative [%X{flow}] %-5level %X{ip} %logger{80} - %msg%n</pattern>
</encoder>
</appender>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<smtpHost>mailhost.jp.fid-intl.com</smtpHost>
<to>xxx@xxx.com</to>
<from>xxx@xxx.com</from>
<subject>[${API_ENV}][%-5level][HK-API${log.mail.subject.suffix}] %logger{80}</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date %-5level %logger{80}.%M - %message%n</pattern>
</layout>
</appender>
<logger name="com.lee" level="debug" />
<logger name="PerformanceCounter" additivity="false">
<appender-ref ref="PERFORMANCE"/>
</logger>
<logger name="MethodLogging">
<appender-ref ref="METHOD"/>
</logger>
<logger name="com.lee.mapper" additivity="false">
<appender-ref ref="SQL"/>
</logger>
<root level="info">
<appender-ref ref="FILE" />
<appender-ref ref="EMAIL" />
<appender-ref ref="ERROR" />
</root>
</else>
</if>
</configuration>
public class LoggingConverter extends LoggerConverter {
protected String getFullyQualifiedName(ILoggingEvent event) {
String loggerText = MDC.get("method");
return ((StringUtils.isBlank(loggerText)) ? super
.getFullyQualifiedName(event) : loggerText);
}
}