콘솔로 출력하려고합니다. logger.info ("Hello world info."); 다음 코드는 '리소스를 찾을 수 없습니다'반환하지만 //이 ...Logback 리소스 logback.xml을 찾을 수 없습니다.
을 잘 작동 오류 :
Logger logger = LoggerFactory.getLogger("framework.Utilities._Test");
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
나는 다음과 같은 XML 사용하고 있습니다 :
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>C:\Reports\logBack.log</file>
<!-- encoders are assigned by default the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
그리고 나 '를 내 클래스 경로 (Windows7 \ 환경 변수 \ 시스템 변수 \ 경로)의 여러 위치의 루트에 복사 했는데도 '자원을 찾을 수 없음'오류가 발생합니다. 어떤 아이디어?
Let us begin by discussing the initialization steps that logback follows to try to configure itself:
Logback tries to find a file called logback.groovy in the classpath.
If no such file is found, logback tries to find a file called logback-test.xml in the classpath.
If no such file is found, it checks for the file logback.xml in the classpath..
If neither file is found, logback configures itself automatically using the BasicConfigurator which will cause logging output to be directed to the console.
을 그래서 아마도 귀하의 경우 당신이 콘솔의 출력을보고있는 기본 구성을로드에 :
코드를 어떻게 실행하고 있습니까? \ by/for 파일 경로를 바꾸어 시도 할 수 있습니다. 때로는 작동하지 않습니다. –