WildFly not logging after deploying app with Logback

大兔子大兔子 提交于 2020-01-15 06:16:25

问题


I have spring boot application with Logback configured in logback.xml.

This app is deployed as *.war to WildFly 8.2.1 (standalone mode) and has excluded WildFly's logging.

During deployment WildFly logs all messages to console until logback for my application is configured. Last message is like "ch.qos.logback.classic.joran.JoranConfigurator@5ab89105 - Registering current configuration as safe fallback point". After it, my app continues logging into file, but all messages from WildFly are gone (e.g. "WildFly 8.2.0.Final "Tweek" started in 37191ms - Started 2666 of 2795 services (221 services are lazy, passive or on-demand)").

logback.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<contextName>prog</contextName>
<jmxConfigurator />

<include resource="com/app/logback/include.xml" />

<property name="destination" value="${JBOSS_HOME:-./temp}/standalone/log" />
<property name="windowSize" value="21" />
<property name="maxFileSize" value="10000KB" />
<property name="pattern" value="R ${commonPattern}" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>%d{HH:mm:ss.SSS} %-5level %logger{16} - %msg%n</Pattern>
    </layout>
</appender>

<appender name="FILE_APP" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${destination}/prog-app.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${destination}/prog-app.log.%i</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>${windowSize}</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>${maxFileSize}</maxFileSize>
    </triggeringPolicy>
    <encoder>
        <charset>UTF-8</charset>
        <pattern>${pattern}</pattern>
    </encoder>
</appender>

<appender name="FILE_OTHER" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${destination}/prog-other.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${destination}/prog-other.log.%i</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>${windowSize}</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>${maxFileSize}</maxFileSize>
    </triggeringPolicy>
    <encoder>
        <charset>UTF-8</charset>
        <pattern>${pattern}</pattern>
    </encoder>
</appender>

<appender name="FILE_RESTS" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${destination}/prog-rests.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${destination}/prog-rests.log.%i</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>${windowSize}</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>${maxFileSize}</maxFileSize>
    </triggeringPolicy>
    <encoder>
        <charset>UTF-8</charset>
        <pattern>${pattern}</pattern>
    </encoder>
</appender>

<logger name="com.app.prog" level="WARN" additivity="false">
    <appender-ref ref="FILE_APP" />
</logger>

<logger name="com.app.prog.config" level="ERROR" additivity="false">
    <appender-ref ref="FILE_RESTS" />
</logger>

<logger name="com.app.prog.processing" level="ERROR" additivity="false">
    <appender-ref ref="FILE_APP" />
</logger>

<logger name="org.springframework.security" level="WARN" additivity="false">
    <appender-ref ref="FILE_OTHER" />
</logger>

<root level="WARN">
    <appender-ref ref="FILE_OTHER" />
</root>
</configuration>

include.xml:

<included>
    <conversionRule conversionWord="pid" converterClass="com.app.logback.converters.ProcessIdConverter" />
    <conversionRule conversionWord="tid" converterClass="com.app.logback.converters.ThreadIdConverter" />
    <conversionRule conversionWord="memory" converterClass="com.app.logback.converters.MemoryConverter" />

    <property name="commonPattern" value="00000 %.-1level %d{yyyy-MM-dd'T'HH:mm:ss.SSS} P%replace(%6pid){' ', '0'} T%replace(%6tid){' ', '0'} M%replace(%10memory){' ', '0'} -- %msg [%logger{0}:%line]%n" />
</included>

jboss-deployment-structure.xml:

<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

logback output (it is also unexpected that it is printed with debug="false" attribute):

14:04:57,897 INFO  [stdout] (MSC service thread 1-9) 14:04:57,747 |-INFO in ch.qos.logback.classic.LoggerContext[prog] - Could NOT find resource [logback.groovy]
14:04:57,902 INFO  [stdout] (MSC service thread 1-9) 14:04:57,748 |-INFO in ch.qos.logback.classic.LoggerContext[prog] - Could NOT find resource [logback-test.xml]
14:04:57,909 INFO  [stdout] (MSC service thread 1-9) 14:04:57,748 |-INFO in ch.qos.logback.classic.LoggerContext[prog] - Found resource [logback.xml] at [vfs:/C:/inst/wildfly-8.2.1.Final/bin/content/prog-0.1.0.war/WEB-INF/classes/logback.xml]
14:04:57,932 INFO  [stdout] (MSC service thread 1-9) 14:04:57,759 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@4883a060 - URL [vfs:/C:/inst/wildfly-8.2.1.Final/bin/content/prog-0.1.0.war/WEB-INF/classes/logback.xml] is not of type file
14:04:57,961 INFO  [stdout] (MSC service thread 1-9) 14:04:57,838 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
14:04:57,979 INFO  [stdout] (MSC service thread 1-9) 14:04:57,839 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [prog]
14:04:57,986 INFO  [stdout] (MSC service thread 1-9) 14:04:57,839 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin
14:04:58,002 INFO  [stdout] (MSC service thread 1-9) 14:04:57,842 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@6183db43 - Adding [vfs:/C:/inst/wildfly-8.2.1.Final/bin/content/prog-0.1.0.war/WEB-INF/lib/logging-0.0.1-SNAPSHOT.jar/com/app/logback/includedPattern.xml] to configuration watch list.
14:04:58,016 INFO  [stdout] (MSC service thread 1-9) 14:04:57,842 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@4883a060 - URL [vfs:/C:/inst/wildfly-8.2.1.Final/bin/content/prog-0.1.0.war/WEB-INF/lib/logging-0.0.1-SNAPSHOT.jar/com/app/logback/includedPattern.xml] is not of type file
14:04:58,047 INFO  [stdout] (MSC service thread 1-9) 14:04:57,844 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word pid with class [com.app.logback.converters.ProcessIdConverter]
14:04:58,073 INFO  [stdout] (MSC service thread 1-9) 14:04:57,844 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word tid with class [com.app.logback.converters.ThreadIdConverter]
14:04:58,092 INFO  [stdout] (MSC service thread 1-9) 14:04:57,844 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word memory with class [com.app.logback.converters.MemoryConverter]
14:04:58,101 INFO  [stdout] (MSC service thread 1-9) 14:04:57,848 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
14:04:58,109 INFO  [stdout] (MSC service thread 1-9) 14:04:57,850 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
14:04:58,129 INFO  [stdout] (MSC service thread 1-9) 14:04:57,873 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
14:04:58,175 INFO  [stdout] (MSC service thread 1-9) 14:04:57,873 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
14:04:58,182 INFO  [stdout] (MSC service thread 1-9) 14:04:57,873 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
14:04:58,190 INFO  [stdout] (MSC service thread 1-9) 14:04:57,873 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
14:04:58,209 INFO  [stdout] (MSC service thread 1-9) 14:04:57,875 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE_APP]
14:04:58,215 INFO  [stdout] (MSC service thread 1-9) 14:04:57,880 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@1594e85 - No compression will be used
14:04:58,235 INFO  [stdout] (MSC service thread 1-9) 14:04:57,884 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:04:58,244 INFO  [stdout] (MSC service thread 1-9) 14:04:57,887 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE_APP] - Active log file name: C:\inst\wildfly-8.2.1.Final/standalone/log/prog-app.log
14:04:58,265 INFO  [stdout] (MSC service thread 1-9) 14:04:57,887 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE_APP] - File property is set to [C:\inst\wildfly-8.2.1.Final/standalone/log/prog-app.log]
14:04:58,273 INFO  [stdout] (MSC service thread 1-9) 14:04:57,888 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
14:04:58,295 INFO  [stdout] (MSC service thread 1-9) 14:04:57,888 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE_OTHER]
14:04:58,301 INFO  [stdout] (MSC service thread 1-9) 14:04:57,889 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@70cb31ef - No compression will be used
14:04:58,324 INFO  [stdout] (MSC service thread 1-9) 14:04:57,889 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:04:58,342 INFO  [stdout] (MSC service thread 1-9) 14:04:57,890 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE_OTHER] - Active log file name: C:\inst\wildfly-8.2.1.Final/standalone/log/prog-other.log
14:04:58,353 INFO  [stdout] (MSC service thread 1-9) 14:04:57,890 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE_OTHER] - File property is set to [C:\inst\wildfly-8.2.1.Final/standalone/log/prog-other.log]
14:04:58,375 INFO  [stdout] (MSC service thread 1-9) 14:04:57,890 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
14:04:58,384 INFO  [stdout] (MSC service thread 1-9) 14:04:57,890 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE_RESTS]
14:04:58,391 INFO  [stdout] (MSC service thread 1-9) 14:04:57,891 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@259e0f36 - No compression will be used
14:04:58,411 INFO  [stdout] (MSC service thread 1-9) 14:04:57,891 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:04:58,427 INFO  [stdout] (MSC service thread 1-9) 14:04:57,892 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE_RESTS] - Active log file name: C:\inst\wildfly-8.2.1.Final/standalone/log/prog-rests.log
14:04:58,440 INFO  [stdout] (MSC service thread 1-9) 14:04:57,892 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE_RESTS] - File property is set to [C:\inst\wildfly-8.2.1.Final/standalone/log/prog-rests.log]
14:04:58,459 INFO  [stdout] (MSC service thread 1-9) 14:04:57,893 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.app.prog] to WARN
14:04:58,475 INFO  [stdout] (MSC service thread 1-9) 14:04:57,893 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.app.prog] to false
14:04:58,488 INFO  [stdout] (MSC service thread 1-9) 14:04:57,893 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE_APP] to Logger[com.app.prog]
14:04:58,506 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.app.prog.config] to ERROR
14:04:58,523 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.app.prog.config] to false
14:04:58,540 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE_RESTS] to Logger[com.app.prog.config]
14:04:58,555 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.app.prog.processing] to ERROR
14:04:58,572 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.app.prog.processing] to false
14:04:58,588 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE_APP] to Logger[com.app.prog.processing]
14:04:58,607 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.security] to WARN
14:04:58,622 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.springframework.security] to false
14:04:58,663 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE_OTHER] to Logger[org.springframework.security]
14:04:58,673 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
14:04:58,688 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE_OTHER] to Logger[ROOT]
14:04:58,703 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
14:04:58,709 INFO  [stdout] (MSC service thread 1-9) 14:04:57,894 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5ab89105 - Registering current configuration as safe fallback point

Probably something is with my logback.xml configuration, but I can't figure out what exactly (I'm not a big guru in WildFly and Logback configuration).

Any help is appreciated. Thanks.

EDIT: It becomes working when I remove <root> section from logback.xml

来源:https://stackoverflow.com/questions/40914684/wildfly-not-logging-after-deploying-app-with-logback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!