정미나닷컴

[Java] Spring boot 날짜별로 로그 쌓기 본문

programming

[Java] Spring boot 날짜별로 로그 쌓기

정미나 2021. 11. 10. 19:39
반응형
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="300 seconds">
    <property resource="application.properties"/>
    
    <appender name="FILE_LOCAL" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>D:/emart-cc/workspace/SSGMemberInfo/log/ssgPointLog.log</file>
		<append>true</append>
		<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<fileNamePattern>D:/emart-cc/workspace/SSGMemberInfo/log/ssgPointLog-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
			<maxFileSize>100MB</maxFileSize>
			<maxHistory>10</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>
				%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) [ %cyan(%logger) ] : %msg%n
			</pattern>
		</encoder>
	</appender>
        
    <property name="DIR_SERVER" value="/home/sysadm/ssg-point/log"/>
	<appender name="FILE_SERVER" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${DIR_SERVER}/ssgPointLog.log</file>
		<append>true</append>
		<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<fileNamePattern>${DIR_SERVER}/ssgPointLog-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
			<maxFileSize>100MB</maxFileSize>
			<maxHistory>90</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>
				%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) [ %cyan(%logger) ] : %msg%n
			</pattern>
		</encoder>
    </appender>
    
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
      <layout class="ch.qos.logback.classic.PatternLayout">
        <pattern>%d{yyyy-MM-dd HH:mm:ss} [%-5p] [%F]%M\(%L\) : %m%n</pattern>
      </layout>
    </appender>

	<logger name="org.springframework" level="INFO" />
	<logger name="jdbc.sqltiming" level="INFO" />
	<logger name="jdbc.sqlonly" level="DEBUG" />
	<logger name="jdbc.resultsettable" level="DEBUG" />
	<logger name="org.apache.http.impl.conn" level="INFO" />
	<logger name="jdbc" level="INFO"/>

	<!-- 설정 파일의 active에 따라 로그 출력 -->
	<springProfile name="prod">
		<root level="INFO">
			<appender-ref ref="FILE_SERVER"/>
		</root>
	</springProfile>
	<springProfile name="dev">
		<root level="DEBUG">
			<appender-ref ref="FILE_SERVER"/>
		</root>
	</springProfile>
	<springProfile name="local">
		<root level="DEBUG">
			<appender-ref ref="STDOUT" />
			<appender-ref ref="FILE_LOCAL"/>
		</root>
	</springProfile>

</configuration>
반응형
0 Comments
댓글쓰기 폼