Reputation: 303
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?
Upvotes: 10
Views: 9533
Reputation: 422
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.
Upvotes: 0
Reputation: 1216
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.
Upvotes: 8