써먹는 웹개발
egov 전자정부프레임워크 mariadb mybatis 로그 출력 (log4j2) 본문
728x90
반응형
※ egov 전자정부프레임워크는 log4jdbc-remix가 사용되지 않습니다.
1. pom.xml
1
2
3
4
5
6
7
8
9
10
11
|
<!-- mybatis log4jdbc-log4j2 라이브러리 -->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4</artifactId>
<version>1.16</version>
</dependency>
<dependency>
<groupId>net.sf</groupId>
<artifactId>log4jdbc3</artifactId>
<version>1.1</version>
</dependency>
|
cs |
2. context-datasource.xml
1
2
3
4
5
|
DataBase.DriverClassName=org.mariadb.jdbc.Driver
=>DataBase.DriverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
DataBase.Url=jdbc:mariadb://localhost:3306/utilMakeDB
=>DataBase.Url=jdbc:log4jdbc:mariadb://localhost:3306/utilMakeDB
|
cs |
3. ( resources > ) log4jdbc.log4j2.properties
1
2
3
|
log4jdbc.drivers=org.mariadb.jdbc.Driver
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
log4jdbc.dump.sql.maxlinelength=0
|
cs |
4. ( resources > ) logback.xml
1
2
3
4
5
6
7
8
9
10
11
|
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<!-- log4jdbc-log4j2 -->
<logger name="jdbc.sqlonly" level="DEBUG"/>
<logger name="jdbc.sqltiming" level="INFO"/>
<logger name="jdbc.audit" level="WARN"/>
<logger name="jdbc.resultset" level="ERROR"/>
<logger name="jdbc.resultsettable" level="ERROR"/>
<logger name="jdbc.connection" level="INFO"/>
</configuration>
|
cs |
5. ( 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
|
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<!-- Console 출력을 위한 Appender -->
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %5p [%c] %m%n" />
</Console>
<!-- 로그파일 생성을 위한 Appender -->
<RollingFile name="dailyRollingFileAppender" fileName="d:/tdms_logs/tdms.log" filePattern="d:/tdms_logs/tdms_%d{yyyy-MM-dd}.log" append="true">
<PatternLayout pattern="%d %5p [%c] %m%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="java.sql" level="INFO" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="dailyRollingFileAppender" />
</Logger>
<Logger name="egovframework" level="DEBUG" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="dailyRollingFileAppender" />
</Logger>
<!-- log SQL with timing information, post execution -->
<Logger name="jdbc.sqltiming" level="INFO" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="dailyRollingFileAppender" />
</Logger>
<Logger name="org.springframework" level="INFO" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="dailyRollingFileAppender" />
</Logger>
<Root level="INFO">
<AppenderRef ref="console" />
<AppenderRef ref="dailyRollingFileAppender" />
</Root>
</Loggers>
</Configuration>
|
cs |
차례대로 추가 및 수정
출처 : https://rhkdgus0779.tistory.com/53
출처의 출처 : https://www.leafcats.com/45
728x90
반응형
'Server > Spring' 카테고리의 다른 글
[Spring] MySQL) com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 에러 해결방법 (0) | 2023.08.09 |
---|---|
egov 전자정부프레임워크 4.16 에서 javascript 파일 컬러로 변경되게 수정 (0) | 2023.06.13 |
Configuration problem: Bean name 'dataSource' is already used in this <beans> element (0) | 2023.06.12 |
[Spring] Session(세션) 유지시간 설정방법 (0) | 2023.06.01 |
[Spring] PSA (0) | 2023.04.20 |
Comments