Reputation: 899
I'm trying to deploy a spring-boot application using logback to an existing WildFly 8 container, but as soon as the application has deployed all the container logs stop being written to server.log
and end up being captured by the application logs.
The symptoms are similar to those described in WildFly not logging after deploying app with Logback. If I deploy an application which manually contains logback/slf4j dependencies, the application behaves as I'd expect (application logs go to application logfile, container logs go to server.log), so I'm assuming it's something to do with spring-boot? Can I configure this such that the container logging continues to be handled by Wildfly?
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.logging</groupId>
<artifactId>logger-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="path_base" value="d:/test-logger/" />
<property name="pattern"
value="%date{ISO8601} %level %class{30} %thread %msg %mdc %ex{full} %n" />
<!-- Simple File Appender -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${path_base}test-logger.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${path_base}/archive/%d{yyyy-MM,aux}/test-logger.log.%d.%i.gz
</fileNamePattern>
<maxHistory>90</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date{ISO8601} %level %class{30} %thread %msg %mdc %ex{full} %n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="file" />
</root>
</configuration>
jboss-deployment.xml
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
Spring boot initializer
package com.test;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class BootApp extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder builder) {
return builder.sources(BootApp.class);
}
}
Upvotes: 1
Views: 2220
Reputation: 1025
I had a similar problem: Running Spring-boot 1.5.8 on Wildfly 9.0.2Final
I had to exclude the following before the logging was handled by the container:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
spring-boot-starter-data-jpa
has spring-boot-starter-logging
which had the dependencies i excluded.
Upvotes: 0
Reputation: 11
I had similar problem when I deployed spring-boot application to websphere. After application prints banner all the log messages from websphere are logged into application log.
The problem occurred because spring-boot adds as one of its dependencies jul-to-slf4j.jar . This jar implements classes java.util.logging.* and websphere is also using java.util.logging hence by excluding jul-to-slf4j.jar from spring boot I was able to direct all websphere messages to container log and the application logs were written to application log.
Upvotes: 1