9

I have a Spring boot application prepare to be a WAR. It deploys without problems on Tomcat 8 (embedded or standalone) as well as on JBoss 8 Wildfly.
But while on Tomcat we have had configured working logback configuration on JBoos it does not work any more.

I have tried few different suggested solutions:
https://stackoverflow.com/a/21887529/3997870
https://stackoverflow.com/a/23080264/3997870

The best which I have found was to add to my project WEB-INF/jboss-deployment-structure.xml with

<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>

but still it does not solve problem completely. In the logs I have same line twice (not because of logback configuration because on Tomcat worked properly) and also double info about time, level, thread was printed in first record.

[2014-11-26 15:28:42,605] [INFO ] [MSC service thread 1-3        ] [stdout] [NONE      ] [2014-11-26 15:28:42.605  INFO 8228 --- [vice thread 1-3] o.s.boot.SpringApplication               : Starting application on LCJLT306 with PID 8228 (started by Piotr.Konczak in D:\servers\wildfly-8.2.0.Final\bin)
]
[2014-11-26 15:28:42,605] [INFO ] [MSC service thread 1-3        ] [o.s.boot.SpringApplication] [NONE      ] [Starting application on LCJLT306 with PID 8228 (started by Piotr.Konczak in D:\servers\wildfly-8.2.0.Final\bin)]

As you can see in above example first record contains somehow additional timestamp, level and thread (I guess add by Wildfly during some redirect) while the second line is proper and expected.

My logback config has 2 parts - 1st inside app and 2nd outside app to make it possible to reconfigure in environments).
Inside the classpath:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml" />
    <include file="/opt/appName/config/appNameLogConfig.xml" />
</configuration>

Outside the app (included one):

<?xml version="1.0" encoding="UTF-8"?>
<included>

    <property name="DESTINATION_FOLDER" value="/opt/appName/logs" />
    <property name="FILE_NAME" value="AppName" />

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${DESTINATION_FOLDER}/${FILE_NAME}.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--daily rollover-->
            <fileNamePattern>${DESTINATION_FOLDER}/${FILE_NAME}.%d{yyyy-MM-dd}.log</fileNamePattern>
        </rollingPolicy>

        <encoder>
            <pattern>%-5level %date %-30thread %-30logger{30} [%-10mdc{requestId:-NONE}] %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="org.springframework" level="INFO"/>
    <logger name="org.hibernate" level="INFO"/>
    <logger name="com.wordnik" level="INFO"/>
    <logger name="com.mangofactory" level="INFO"/>
    <logger name="com.company.appName" level="INFO"/>

    <root level="INFO">
        <appender-ref ref="FILE" />
    </root>
</included>

Does anyone see possible reason or misconfiguration?

Community
  • 1
  • 1
Piotr Kończak
  • 193
  • 1
  • 3
  • 10
  • What logging facade are you using? – James R. Perkins Nov 28 '14 at 21:44
  • I don't know anything about Spring Boot. Does it launch WildFly or do you deploy it to WildFly? – James R. Perkins Dec 02 '14 at 22:18
  • I deploy application on WildFly container. – Piotr Kończak Dec 03 '14 at 09:41
  • Is the example log output from the server.log? It doesn't look like the default format and matches the format in your logback configuration more. – James R. Perkins Dec 04 '14 at 19:09
  • No it is not from server.log. I didn't like to disable logging for JBoss completely, so I have disabled logging system using jboss-deployment-structure.xml inside WAR. Then my logback configuration works and put logs into specified file but with double line as described above. – Piotr Kończak Dec 05 '14 at 13:29
  • Did you ever figure this out? – mad_fox Nov 04 '17 at 13:10
  • Unfortunately we didn't. While it was unacceptable to allow mixing logs from different apps and we couldn't make it work we decided to drop usage of WildFly in favor of containerized Spring boot apps on standalone Tomcats. We used ELK stack to collect and manage logs from distributed environment. Personally I think it was the best idea to leave WildFly for Java EE solutions and use something lighter for Spring apps. Also ELK give us quite nice experience as well. – Piotr Kończak Nov 06 '17 at 09:18

2 Answers2

7

I know it is a little bit late but, if some of you face this problem, an alternative is: Don't disable the whole logging subsystem, instead just exclude slf4j libraries provided by JBoss/Wildfly, to use the one used by spring-boot.

<jboss-deployment-structure>
  <deployment>
    <exclusions>
      <module name='org.slf4j'/>
      <module name='org.slf4j.impl'/>
    </exclusions>
  </deployment>
</jboss-deployment-structure>

Hope helps somebody.

carpinchosaurio
  • 1,175
  • 21
  • 44
  • 2
    This works. For everyone else, you need to add the answer in a `WEB-INF\jboss-deployment-structure.xml` file, if it doesn't exist just create a new one. – Jose-Rdz Jan 18 '21 at 00:06
0

I am using my own logging configuration, log4j2 xml instead of spring's logging and faced the same issue with the Wildfly. I commented the whole subsytem system for over-riding that.