2016-04-14 30 views
0

Bugün farkettim ki, log4j2 kullanıyorduk ve log4j özellikler dosyam kullanılmıyordu. Bu yüzden, kullanılmakta olduğunu doğrulamak için en temel log4j2.xml dosyalarına girdim. Günlüklerimden hiçbirini onunla birlikte görmeyi beklemiyordum, ama hepsine bak. Kimse bana seviye setinin neden onur verilmediğine işaret edebilir mi? İşte INFO günlüklerim neden kapalı olduğunda günlüğe kaydediliyor?

benim dosyasıdır:

<?xml version="1.0" encoding="UTF-8"?> 
<Configuration status="trace" packages=""> 
    <Appenders> 
    <Console name="Console" target="SYSTEM_OUT"> 
     <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> 
    </Console> 
    </Appenders> 
    <Loggers> 
    <Root level="off"> 
     <AppenderRef ref="Console"/> 
    </Root> 
    </Loggers> 
</Configuration> 

Log4J başlangıç ​​izleme günlüğü:

2016-04-14 10:40:26,916 localhost-startStop-1 DEBUG Initializing configuration XmlConfiguration[location=C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml] 
2016-04-14 10:40:26,924 localhost-startStop-1 DEBUG Installed script engines 
2016-04-14 10:40:27,325 localhost-startStop-1 DEBUG Oracle Nashorn Version: 1.8.0_72, Language: ECMAScript, Threading: Not Thread Safe, Compile: true, Names: {nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript} 
2016-04-14 10:40:27,326 localhost-startStop-1 DEBUG PluginManager 'Core' found 97 plugins 
2016-04-14 10:40:27,326 localhost-startStop-1 DEBUG PluginManager 'Level' found 0 plugins 
2016-04-14 10:40:27,329 localhost-startStop-1 DEBUG No scheduled items 
2016-04-14 10:40:27,330 localhost-startStop-1 DEBUG PluginManager 'Lookup' found 13 plugins 
2016-04-14 10:40:27,332 localhost-startStop-1 DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. 
2016-04-14 10:40:27,343 localhost-startStop-1 TRACE TypeConverterRegistry initializing. 
2016-04-14 10:40:27,344 localhost-startStop-1 DEBUG PluginManager 'TypeConverter' found 23 plugins 
2016-04-14 10:40:27,357 localhost-startStop-1 DEBUG PatternLayout$Builder(pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n", PatternSelector=null, Configuration(C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", noConsoleNoAnsi="null", header="null", footer="null") 
2016-04-14 10:40:27,357 localhost-startStop-1 DEBUG PluginManager 'Converter' found 38 plugins 
2016-04-14 10:40:27,358 localhost-startStop-1 DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender]. 
2016-04-14 10:40:27,360 localhost-startStop-1 INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory. 
2016-04-14 10:40:27,361 localhost-startStop-1 DEBUG PluginManager 'Converter' found 38 plugins 
2016-04-14 10:40:27,362 localhost-startStop-1 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream 
2016-04-14 10:40:27,363 localhost-startStop-1 DEBUG Starting OutputStreamManager SYSTEM_OUT.false-2 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG ConsoleAppender$Builder(PatternLayout(%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n), Filter=null, target="SYSTEM_OUT", name="Console", follow="null", ignoreExceptions="null") 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG Starting OutputStreamManager SYSTEM_OUT.false 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin]. 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG createAppenders(={Console}) 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef]. 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG createAppenderRef(ref="Console", level="null", Filter=null) 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger]. 
2016-04-14 10:40:27,368 localhost-startStop-1 DEBUG createLogger(additivity="null", level="OFF", includeLocation="null", ={Console}, ={}, Configuration(C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml), Filter=null) 
2016-04-14 10:40:27,385 localhost-startStop-1 DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin]. 
2016-04-14 10:40:27,386 localhost-startStop-1 DEBUG createLoggers(={root}) 
2016-04-14 10:40:27,387 localhost-startStop-1 DEBUG Configuration XmlConfiguration[location=C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml] initialized 
2016-04-14 10:40:27,387 localhost-startStop-1 DEBUG Starting configuration XmlConfiguration[location=C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml] 
2016-04-14 10:40:27,387 localhost-startStop-1 DEBUG Started configuration XmlConfiguration[location=C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml] OK. 
2016-04-14 10:40:27,388 localhost-startStop-1 TRACE Stopping [email protected]52... 
2016-04-14 10:40:27,388 localhost-startStop-1 TRACE DefaultConfiguration notified 1 ReliabilityStrategies that config will be stopped. 
2016-04-14 10:40:27,388 localhost-startStop-1 TRACE DefaultConfiguration stopping root LoggerConfig. 
2016-04-14 10:40:27,388 localhost-startStop-1 TRACE DefaultConfiguration notifying ReliabilityStrategies that appenders will be stopped. 
2016-04-14 10:40:27,389 localhost-startStop-1 TRACE DefaultConfiguration stopping remaining Appenders. 
2016-04-14 10:40:27,389 localhost-startStop-1 DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false-1 
2016-04-14 10:40:27,389 localhost-startStop-1 TRACE DefaultConfiguration stopped 1 remaining Appenders. 
2016-04-14 10:40:27,389 localhost-startStop-1 TRACE DefaultConfiguration cleaning Appenders from 1 LoggerConfigs. 
2016-04-14 10:40:27,390 localhost-startStop-1 DEBUG Stopped [email protected]52 OK 
2016-04-14 10:40:27,392 localhost-startStop-1 TRACE Reregistering MBeans after reconfigure. Selector=or[email protected]59c13ee7 
2016-04-14 10:40:27,393 localhost-startStop-1 TRACE Reregistering context (1/1): '535ee47f' [email protected] 
2016-04-14 10:40:27,394 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f' 
2016-04-14 10:40:27,394 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=StatusLogger' 
2016-04-14 10:40:27,394 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=ContextSelector' 
2016-04-14 10:40:27,395 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=Loggers,name=*' 
2016-04-14 10:40:27,395 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=Appenders,name=*' 
2016-04-14 10:40:27,395 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=AsyncAppenders,name=*' 
2016-04-14 10:40:27,396 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=AsyncLoggerRingBuffer' 
2016-04-14 10:40:27,396 localhost-startStop-1 TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=535ee47f,component=Loggers,name=*,subtype=RingBuffer' 
2016-04-14 10:40:27,398 localhost-startStop-1 DEBUG Registering MBean org.apache.logging.log4j2:type=535ee47f 
2016-04-14 10:40:27,402 localhost-startStop-1 DEBUG Registering MBean org.apache.logging.log4j2:type=535ee47f,component=StatusLogger 
2016-04-14 10:40:27,405 localhost-startStop-1 DEBUG Registering MBean org.apache.logging.log4j2:type=535ee47f,component=ContextSelector 
2016-04-14 10:40:27,407 localhost-startStop-1 DEBUG Registering MBean org.apache.logging.log4j2:type=535ee47f,component=Loggers,name= 
2016-04-14 10:40:27,410 localhost-startStop-1 DEBUG Registering MBean org.apache.logging.log4j2:type=535ee47f,component=Appenders,name=Console 
2016-04-14 10:40:27,416 localhost-startStop-1 TRACE Using default SystemClock for timestamps. 
2016-04-14 10:40:27,418 localhost-startStop-1 TRACE Using DummyNanoClock for nanosecond timestamps. 
2016-04-14 10:40:27,418 localhost-startStop-1 DEBUG Reconfiguration complete for context[name=535ee47f] at URI C:\Workspaces\Q1Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestLicense\WEB-INF\classes\log4j2.xml ([email protected]) with optional ClassLoader: null 

benim uygulamadan bilgi mesajları oturum devam ettiğini Buraya bakın:

Apr 14, 2016 12:02:46 PM com.myorg.licensing.persistence.dao.ext.S1ProductDaoExt update 
INFO: updating S1Product instance 
Apr 14, 2016 12:02:46 PM com.myorg.licensing.persistence.dao.ext.S1ProductDaoExt update 
INFO: update successful 
Apr 14, 2016 12:02:52 PM com.myorg.licensing.persistence.dao.ext.S1ProductDaoExt update 
INFO: updating S1Product instance 
Apr 14, 2016 12:02:52 PM com.myorg.licensing.persistence.dao.ext.S1ProductDaoExt update 
INFO: update successful 
Apr 14, 2016 12:02:56 PM com.myorg.licensing.persistence.dao.ext.S1ProductDaoExt update 
INFO: updating S1Product instance 
Apr 14, 2016 12:02:56 PM com.myorg.licensing.persistence.dao.ext.S1ProductDaoExt update 
INFO: update successful 
+0

** Kapalı ** olan her şeyle ne görmeyi beklersiniz? – Fildor

+0

Normalde kapalı olarak ayarlanmayacaktı, ancak ayarladığım seviyeye bağlı olarak değişmesi mümkün görünmüyor. Bu yüzden onu devre dışı bıraktım, başvurumdan hiçbir kayıt görmeyi beklemiyordum. Ancak ben tam tersini görüyorum, HER ŞEYİ görüyorum. – nmb1106

+1

Log4j dahili günlüklerini görmek için durumu "izleme" veya "hata ayıklama" olarak deneyin ve ayarlayın. Belki bir ipucu alırsın. Başlangıç ​​mesajlarını görmek için yapılandırmayı değiştirdikten sonra uygulamayı yeniden başlatın. – Fildor

cevap

0

Benim hazırda Modeller tersine veri tabanından oluşturulmakta ve org.apache.commons.logging ile üretilmektedir. Uygun Log4j2 sınıfları yerine log ve org.apache.commons.logging.LogFactory.

Yukarıdaki Log4j2 yapılandırmaları aslında tüm dahili Log4j2 günlüklerini kapatarak, hala konsola eklenmiş olan Apache commons günlükleridir.

+0

Log4j 2'nin yanı sıra başka bir günlük uygulamanız var mı? Log4j 2 - Commons Logging adaptörünü kullanırsanız Log4j 2 bunları da kullanabilmelidir. – rgoers

+0

MyEclipse JPA Tersine Mühendislik aracı bir Log4j1 uygulamasına geçiyordu. Log4j2'yi kullanmak için reveng şablonlarını özelleştirdim ve şimdi beklendiği gibi çalışıyor. – nmb1106