2014-04-15 19 views
15

Eseguo l'applicazione Web in WildFly 8 e per qualche motivo non registra. Io uso SLF4J con LOGBACK. Il file di registro viene creato su deploy ma è vuoto. Non vedo nemmeno le mie dichiarazioni di registro nei log di wildfly.SLF4J + Logback non effettua il login in WildFly

la classe contiene:

package com.blah.oops; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

static final Logger log = LoggerFactory.getLogger(EndpointImpl.class); 

log.debug("request called"); 

Guerra contiene:

  • WEB-INF \ lib \ slf4j-api-1.7.5.jar
  • WEB-INF \ lib \ logback- classico 1.1.1.jar
  • WEB-INF \ lib \ logback-core-1.1.1.jar
  • WEB-INF \ classes \ logback.xml

configurazione del file logback.xml contiene:

<configuration scan="true" scanPeriod="10 seconds"> 
    <appender name="FILE" class="ch.qos.logback.core.FileAppender"> 
     <file>${LOG_PATH}/backend-main.log</file> 
     <encoder> 
      <pattern>%date %level [%thread] %logger{10} %msg%n</pattern> 
     </encoder> 
    </appender> 

    <!-- PROFILER configuration --> 
    <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter"> 
     <Marker>PROFILER</Marker> 
     <OnMatch>ACCEPT</OnMatch> 
     <!-- <OnMatch>DENY</OnMatch> --> 
    </turboFilter> 

    <logger name="org.eclipse.jetty.util.log" level="info"/> 
    <logger name="com.blah" level="debug"/> 
    <logger name="org.apache.cxf" level="warn"/> 

    <root level="info"> 
     <appender-ref ref="FILE"/> 
    </root> 
</configuration> 

console.log contiene logback inizializzazione:

.[0m.[0m10:19:52,716 INFO [stdout] (MSC service thread 1-2) 10:19:52,489 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 
.[0m.[0m10:19:52,717 INFO [stdout] (MSC service thread 1-2) 10:19:52,489 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 
.[0m.[0m10:19:52,717 INFO [stdout] (MSC service thread 1-2) 10:19:52,490 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [vfs:/content/backend.war/WEB-INF/classes/logback.xml] 
.[0m.[0m10:19:52,717 INFO [stdout] (MSC service thread 1-2) 10:19:52,501 |-INFO in [email protected] - URL [vfs:/content/backend.war/WEB-INF/classes/logback.xml] is not of type file 
.[0m.[0m10:19:52,717 INFO [stdout] (MSC service thread 1-2) 10:19:52,524 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 
.[0m.[0m10:19:52,717 INFO [stdout] (MSC service thread 1-2) 10:19:52,529 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 10 seconds 
.[0m.[0m10:19:52,718 INFO [stdout] (MSC service thread 1-2) 10:19:52,529 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[]] every 10 seconds. 
.[0m.[0m10:19:52,718 INFO [stdout] (MSC service thread 1-2) 10:19:52,529 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter 
.[0m.[0m10:19:52,718 INFO [stdout] (MSC service thread 1-2) 10:19:52,532 |-ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [acquirer.properties]. 
.[0m.[0m10:19:52,718 INFO [stdout] (MSC service thread 1-2) 10:19:52,532 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 
.[0m.[0m10:19:52,718 INFO [stdout] (MSC service thread 1-2) 10:19:52,535 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [jettyConsole] 
.[0m.[0m10:19:52,718 INFO [stdout] (MSC service thread 1-2) 10:19:52,572 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender] 
.[0m.[0m10:19:52,719 INFO [stdout] (MSC service thread 1-2) 10:19:52,573 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE] 
.[0m.[0m10:19:52,719 INFO [stdout] (MSC service thread 1-2) 10:19:52,575 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 
.[0m.[0m10:19:52,719 INFO [stdout] (MSC service thread 1-2) 10:19:52,576 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [/var/log/blah/backend-main.log] 
.[0m.[0m10:19:52,719 INFO [stdout] (MSC service thread 1-2) 10:19:52,591 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.log] to INFO 
.[0m.[0m10:19:52,719 INFO [stdout] (MSC service thread 1-2) 10:19:52,592 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.blah] to DEBUG 
.[0m.[0m10:19:52,719 INFO [stdout] (MSC service thread 1-2) 10:19:52,592 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.cxf] to WARN 
.[0m.[0m10:19:52,720 INFO [stdout] (MSC service thread 1-2) 10:19:52,592 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO 
.[0m.[0m10:19:52,720 INFO [stdout] (MSC service thread 1-2) 10:19:52,713 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT] 
.[0m.[0m10:19:52,720 INFO [stdout] (MSC service thread 1-2) 10:19:52,713 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 
.[0m.[0m10:19:52,720 INFO [stdout] (MSC service thread 1-2) 10:19:52,714 |-INFO in [email protected] - Registering current configuration as safe fallback point 

Mi sembra che logback è configurato con successo. Ma i messaggi di log sono persi. Qualche idea su cosa sta andando lì? Non ha senso.

+0

ho risposto qui: http://stackoverflow.com/a/26342226/3472929. Spero che sia d'aiuto. – user3472929

risposta

20

WildFly aggiunge slf4j come dipendenza di registrazione predefinita Avete provato a escludere l'implementazione principale nel descrittore jboss-deployment-structure.xml (Dovrebbe andare sotto la directory META-INF). Questo può essere fatto con le linee di seguito:

<?xml version="1.0" encoding="UTF-8"?> 
<jboss-deployment-structure> 
    <deployment> 
    <exclusions> 
     <module name="org.apache.commons.logging" /> 
     <module name="org.apache.log4j" /> 
     <module name="org.jboss.logging" /> 
     <module name="org.jboss.logging.jul-to-slf4j-stub" /> 
     <module name="org.jboss.logmanager" /> 
     <module name="org.jboss.logmanager.log4j" /> 
     <module name="org.slf4j" /> 
     <module name="org.slf4j.impl" /> 
    </exclusions> 
    </deployment> 
</jboss-deployment-structure> 
+1

Ho appena trovato la seguente domanda e l'esclusione di help. Grazie non importa. http://stackoverflow.com/questions/21846329/override-logging-in-wildfly?rq=1 –

+0

Felice di averlo risolto :) – tmarwen

+0

Lo sono anch'io. È interessante notare che domande simili sono diverse quando si digita la domanda e quando la domanda è effettivamente presentata. –

4

wildfly sta usando slf4j come la registrazione defult. devi dire a jboss di non usare slf4j, sto usando log4j. si può fare questo usando sotto jboss-distribuzione-structure.xml

<jboss-deployment-structure> 
    <deployment> 
    <!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment --> 
    <!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment --> 
    <exclude-subsystems> 
     <subsystem name="logging" /> 
    </exclude-subsystems> 
    </deployment> 
</jboss-deployment-structure> 
Problemi correlati