cmd로 jar파일 실행시 로그 파일을 날짜별로 자동 생성 시키기.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="dailyRollingFileAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>applicatoin.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<encoder>
<pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<logger name="패키지명" level="INFO"/>
<logger name="패키지명2" level="INFO"/>
<root level="INFO">
<appender-ref ref="dailyRollingFileAppender" />
</root>
</configuration>
src/main/resources
하위에 logback-spring.xml 라는 파일을 위와같이 생성한다.
(로그를찍으려는)패키지명만 사용자에 맞게 기입해주면된다.(ex.com.test.test)
로그레벨도 사용자지정으로 입력한다 (ex.INFO)
이후 프로젝트 빌드 후, 생성된 jar파일을 실행해주면 실행위치에 날짜에 따른 로그파일이 생성된다.
ex. applicatoin.2022-10-27
참고)
반응형
'etc > Spring' 카테고리의 다른 글
[springboot] 프로젝트 세팅 (1) (0) | 2023.02.19 |
---|---|
springboot에서 DB연결 테스트 (0) | 2022.10.27 |
[Spring Boot]Duplicating managed version ~ for ~ (0) | 2022.10.11 |
spring boot 스프링 부트 프로젝트 생성하기 (0) | 2022.10.08 |
@alias 어노테이션 (0) | 2022.07.18 |