2019.08.05
https://mvnrepository.com/search?q=log4j
pom.xml dependency 추가
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<!-- pom.xml -->
<!-- 기본값:logback 제외 exclusion:spring-boot-starter-logging -->
<dependency>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- log4j2 설정 -->
<dependency>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<artifactId>log4j-web</artifactId>
</dependency>
<dependency>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
<version>1.16</version>
</dependency>
|
application.properties 설정
1
2
3
4
5
6
7
8
|
spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/DB이름?serverTimezone=UTC&characterEncoding=UTF8
spring.datasource.username=DB아이디
spring.datasource.password=DB
|
src/main/resources 하위에 파일 추가
log4j2.xml 설정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" monitorInterval="30">
<Properties>
<Property name="LOG_FORMAT">%d{yyyy-MM-dd HH:mm:ss} %p %m%n</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="${LOG_FORMAT}"/>
</Console>
</Appenders>
<Loggers>
<!-- Log everything in custom package -->
<AppenderRef ref="Console" />
</Logger>
<!-- Log everything in Spring Boot -->
<AppenderRef ref="Console" />
</Logger>
<!-- Log everything in Spring Core -->
<AppenderRef ref="Console" />
</Logger>
<Logger name="jdbc" level="error" additivity="false">
<AppenderRef ref="Console" />
</Logger>
<Logger name="jdbc.sqlonly" level="error" additivity="false">
<AppenderRef ref="Console" />
</Logger>
<Logger name="jdbc.sqltiming" level="info" additivity="false">
<AppenderRef ref="Console" />
</Logger>
<AppenderRef ref="Console" />
</Logger>
<Logger name="jdbc.resultset" level="error" additivity="false">
<AppenderRef ref="Console" />
</Logger>
<Logger name="jdbc.resultsettable" level="error" additivity="false">
<AppenderRef ref="Console" />
</Logger>
<Logger name="jdbc.connection" level="error" additivity="false">
<AppenderRef ref="Console" />
</Logger>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
|
'교육 > Spring Boot' 카테고리의 다른 글
#62 Spring Boot 페이징 처리 (0) | 2019.08.08 |
---|---|
#60 Spring Boot 로그인 처리 (0) | 2019.08.06 |
#58 Spring Boot MyBatis trim (0) | 2019.08.05 |
#57 Spring Boot Mybatis SELECT 조건, MyBatis LIKE 사용 (0) | 2019.08.05 |
#54 Spring Boot MyBatis로 MySQL DB 연동 (0) | 2019.08.02 |