Log4J2를 설정하려고하는데 콘솔에 인쇄 할 때 StatusLogger
이 표시되는데 왜 내 설정 파일을 보지 못했는지 이해할 수 있습니다. (궁금한 점은 Log4J2가 사용하지 않는 JSON 라이브러리라고 생각합니다. 내 classpath 그래서 조용히 실패했지만, 불행히도 나는 확실하지 않다). 이 파일 이름, 예를 들어,에 sun.misc.Launcher$AppClassLoader.toString()
통화와 자원을 찾고있는 것 같다 - 나는 TRACE
문을 인쇄 할 StatusLogger
을 설정하면Log4J2가 파일 이름에 클래스 로더 문자열이있는 구성 파일을 찾는 이유는 무엇입니까?
그러나, 나는 이상한 것을 발견 (개행 문자는 가독성을 위해 추가) :
이2013-12-09 01:07:23,938 TRACE Trying to find
[[email protected]]
using context classloader [email protected]
는을 찾고 파일은 기본적으로 홀수로 생각 난 "log4j2"+classLoader+".json"
입니다. 궁극적으로 Loader.getResource()
이 resource
문자열의 일부로서 loader.toString()
의 값 전달 호출하는 호출되고 결국 ctx.start()
로 연결
private LoggerContext locateContext(final ClassLoader loader,
final URI configLocation {
final String name = loader.toString();
...
LoggerContext ctx = new LoggerContext(name, null, configLocation);
...
}
:하지만 설정 로딩 동작을 통해 디버깅, 우리는이 다음을 수행 ClassLoaderContextSelector.locateContext()
에서 유래 참조 . 그것을 보면, 그 행동은 상당히 의도적 인 것처럼 보이지만 그러한 자원 이름을 찾는 것이 왜 유익한 지 상상할 수 없습니다. 이것이 우리에게 무엇을 주는가? 이거 버그 야?
SSCCE :
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.status.StatusConsoleListener;
import org.apache.logging.log4j.status.StatusLogger;
public class L4JTrace {
public static void main(String[] args) {
StatusConsoleListener listener = new StatusConsoleListener(Level.ALL);
StatusLogger.getLogger().registerListener(listener);
LogManager.getLogger(MyApp.class.getName());
}
}
등이 출력해야 뭔가 :
2013-12-09 01:22:27,132 WARN Multiple logging implementations found:
Factory: org.apache.logging.log4j.core.impl.Log4jContextFactory, Weighting: 10
Using factory: org.apache.logging.log4j.core.impl.Log4jContextFactory
2013-12-09 01:22:27,148 DEBUG ServletContext not present - WebLookup not added
2013-12-09 01:22:27,160 DEBUG Found Plugin Map at jar:file:LOCALPATH
2013-12-09 01:22:27,162 DEBUG ServletContext not present - WebLookup not added
2013-12-09 01:22:27,202 WARN JmDNS or serviceInfo class not found java.lang.ClassNotFoundException: javax.jmdns.JmDNS # Exception truncated
2013-12-09 01:22:27,221 DEBUG Generated plugins in 0.062408180 seconds
2013-12-09 01:22:27,240 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
2013-12-09 01:22:27,241 DEBUG Starting OutputStreamManager SYSTEM_OUT
2013-12-09 01:22:27,242 DEBUG Reconfiguration started for context [email protected]
2013-12-09 01:22:27,242 DEBUG Generated plugins in 0.000013583 seconds
2013-12-09 01:22:27,245 DEBUG ServletContext not present - WebLookup not added
2013-12-09 01:22:27,245 DEBUG Missing dependencies for Json support
2013-12-09 01:22:27,245 DEBUG ServletContext not present - WebLookup not added
2013-12-09 01:22:27,245 TRACE Trying to find [[email protected]] using context classloader [email protected]
2013-12-09 01:22:27,246 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,246 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,246 TRACE Trying to find [[email protected]] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,246 TRACE Trying to find [[email protected]] using context classloader [email protected]
2013-12-09 01:22:27,246 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,247 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,247 TRACE Trying to find [[email protected]] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,247 TRACE Trying to find [[email protected]] using context classloader [email protected]
2013-12-09 01:22:27,247 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,247 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,247 TRACE Trying to find [[email protected]] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using context classloader [email protected]
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using [email protected] class loader.
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using [email protected] class loader.
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.jsn] using context classloader [email protected]
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.jsn] using [email protected] class loader.
2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.jsn] using [email protected] class loader.
2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using context classloader [email protected]
2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using [email protected] class loader.
2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using [email protected] class loader.
2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,250 TRACE Trying to find [[email protected]] using context classloader [email protected]
2013-12-09 01:22:27,250 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,250 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,250 TRACE Trying to find [[email protected]] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,250 TRACE Trying to find [[email protected]] using context classloader [email protected]
2013-12-09 01:22:27,251 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,251 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,251 TRACE Trying to find [[email protected]] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,251 TRACE Trying to find [[email protected]] using context classloader [email protected]
2013-12-09 01:22:27,251 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,251 TRACE Trying to find [[email protected]] using [email protected] class loader.
2013-12-09 01:22:27,252 TRACE Trying to find [[email protected]] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using context classloader [email protected]
2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using [email protected] class loader.
2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using [email protected] class loader.
2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.jsn] using context classloader [email protected]
2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.jsn] using [email protected] class loader.
2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.jsn] using [email protected] class loader.
2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.jsn] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using context classloader [email protected]
2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using [email protected] class loader.
2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using [email protected] class loader.
2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using ClassLoader.getSystemResource().
2013-12-09 01:22:27,254 DEBUG ServletContext not present - WebLookup not added
2013-12-09 01:22:27,254 DEBUG Generated plugins in 0.000012075 seconds
2013-12-09 01:22:27,254 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
2013-12-09 01:22:27,261 DEBUG Generated plugins in 0.000015998 seconds
2013-12-09 01:22:27,261 DEBUG Reconfiguration completed
2013-12-09 01:22:27,263 DEBUG ServletContext not present - WebLookup not added
2013-12-09 01:22:27,264 DEBUG Shutting down OutputStreamManager SYSTEM_OUT