상세 컨텐츠

본문 제목

log4j2

스프링

by e7e 2022. 6. 28. 15:55

본문

이것이 정석인지는 아직 미확인

몇개의 에러메세지와 시행착오로 로그 메세지 확인

버젼업으로 무엇이 더 나아진 걸까?  먼저 로그란 것에 관심이 필요할 듯

 

pom.xml

		<!-- Logging -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${org.slf4j-version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>${org.slf4j-version}</version>
			<scope>runtime</scope>
		</dependency>
		
<!-- 	아래 log4j-slf4j-impl과 같은 기능으로 주석처리	
         <dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${org.slf4j-version}</version>
			<scope>runtime</scope>
		</dependency>
 -->
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<version>2.17.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-jcl</artifactId>
			<version>2.17.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-slf4j-impl</artifactId>
			<version>2.17.2</version>
		</dependency>
		<dependency>
			<!-- <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> -->
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.17.2</version>
			<exclusions>
				<exclusion>
					<groupId>javax.mail</groupId>
					<artifactId>mail</artifactId>
				</exclusion>
				<exclusion>
					<groupId>javax.jms</groupId>
					<artifactId>jms</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.sun.jdmk</groupId>
					<artifactId>jmxtools</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.sun.jmx</groupId>
					<artifactId>jmxri</artifactId>
				</exclusion>
			</exclusions>
			<scope>runtime</scope>
		</dependency>

log4j2.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<Configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> 
	<!-- Appenders --> 
	<Appenders> 
	<Console name="console" target="SYSTEM_OUT">
		<PatternLayout pattern="%-5p: %c - %m%n" />
	</Console> 
	</Appenders>
	
	 <!-- Application Loggers -->
	 <Loggers> 
	   	<Logger name="kr.pe.basic" level="DEBUG" additivity="false">
	    	<AppenderRef ref="console" />
	    </Logger> 
	    <Logger name="org.springframework.core" level="DEBUG" additivity="false"> 
	    	<AppenderRef ref="console" /> 
	    </Logger> 
	    <Logger name="org.springframework.beans" level="DEBUG" additivity="false"> 
	    	<AppenderRef ref="console" /> 
	    </Logger> 
	    <Logger name="org.springframework.context" level="DEBUG" additivity="false"> 
	   		<AppenderRef ref="console" /> 
	    </Logger>
	 	<Logger name="org.springframework.web" level="DEBUG" additivity="false"> 
	    	<AppenderRef ref="console" /> 
	    </Logger>
	    <Logger name="org.springframework" level="DEBUG" additivity="false"> 
	    	<AppenderRef ref="console" /> 
	    </Logger> 
	 </Loggers>
</Configuration>

 

 

 

'스프링' 카테고리의 다른 글

sitemesh 적용  (0) 2022.10.12
아주 주의  (2) 2022.06.29
MyBatipse  (0) 2022.06.10
Test  (0) 2022.06.08
rest client  (0) 2022.05.31

관련글 더보기