2
slf4j를 log4j와 함께 사용하고 있으며, 어떤 이유로 내 코드에 쓰는 로그를 제외하고 모든 로그가 표시됩니다 - 스프링 로그, 최대 절전 모드 로그, log4j.properties에 구성된 레벨에서. 그러나 내 기록은 보이지 않습니다.slf4j + log4j는 광산을 제외한 모든 로그를 표시합니다.
메이븐 의존성 : log4j에 log4j에 1.2.17 테스트 내 log4j.propertes 파일이
log4j: Trying to find [log4j.xml] using context classloader [email protected]
log4j: Trying to find [log4j.xml] using [email protected] class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader [email protected]
log4j: Using URL [ile:/C:/x/y/myProject/target/test-classes/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL file:/C:/x/y/myProject/target/test-classes/log4j.properties
그리고 I를 사용하고있는 것을 볼 수
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j.version}</version>
<scope>test</scope>
</dependency>
-Dlog4j.debug
실행 다음 로그 코드를 사용하십시오 :
private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);
LOG.warn("Very informative message");
내 log4j.properties 파일 : 내 로거뿐만 아니라
log4j.logger.com.my.path=DEBUG, console
도움이되지 않습니다 그리고 내가 그것을 인식되고 있음을 볼 수에 대한 특정 라인을 추가
# Define the root logger to the system property "hbase.root.logger".
log4j.rootLogger=DEBUG, console
# Logging Threshold
log4j.threshhold=ALL
#
# console appender
# Add "console" to rootLogger above if you want to use this
#
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %-5p [%t] %C{2}(%L): %m%n
:
Parsing for [com.my.path] with value=[DEBUG, console].
log4j: Level token is [DEBUG].
log4j: Category com.my.path set to DEBUG
아직 아무것도 기록되지 않습니다. 이와
log4j.rootLogger=DEBUG, console
:
log4j.rootLogger = ALL, Console
이 두 줄 삭제 :
당신이 –
아니요, log4j.properites가 필요하지 속성을 모두 게시 및 XML은 파일을 함께하시기 바랍니다, 또한의 log4j.xml을해야합니까 . – apines
당신은'log4j.appender.console = DEBUG, org.apache.log4j.ConsoleAppender'를 추가 할 수 있습니까? –