Spring Log
- commons-logging
+ s, log4j
https://sjh836.tistory.com/161
Controller.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Controller
public class Controller {
private static final Logger logger = LoggerFactory.getLogger(Controller.class);
}
2019-08-21 17:38:27 [INFO ] (Controller.home:120) |LOGINFORM|
src/main/resource/log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p] (%C{1}.%M:%L) %m%n" />
</layout>
</appender>
<!-- Application Loggers -->
<logger name="com" additivity="false">
<level value="info" />
<appender-ref ref="console" />
</logger>
<!-- 3rdparty Loggers -->
<logger name="org.springframework.core">
<level value="info" />
</logger>
<logger name="org.springframework.beans">
<level value="info" />
</logger>
<logger name="org.springframework.context">
<level value="info" />
</logger>
<logger name="org.springframework.web">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="off" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
+ s, log4j
https://sjh836.tistory.com/161
Controller.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Controller
public class Controller {
private static final Logger logger = LoggerFactory.getLogger(Controller.class);
}
2019-08-21 17:38:27 [INFO ] (Controller.home:120) |LOGINFORM|
src/main/resource/log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%-5p] (%C{1}.%M:%L) %m%n" />
</layout>
</appender>
<!-- Application Loggers -->
<logger name="com" additivity="false">
<level value="info" />
<appender-ref ref="console" />
</logger>
<!-- 3rdparty Loggers -->
<logger name="org.springframework.core">
<level value="info" />
</logger>
<logger name="org.springframework.beans">
<level value="info" />
</logger>
<logger name="org.springframework.context">
<level value="info" />
</logger>
<logger name="org.springframework.web">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="off" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
%d{yyyy-MM-dd HH:mm:ss} [%-5p] (%C{1}.%M:%L) %m%n
2019-08-21 17:38:27 [INFO ] (Controller.home:120) |LOGINFORM|
댓글
댓글 쓰기