Good day! I have a project , compiled to a WAR-file and running on wildfly-10.1.0-FINAL. Some time ago I configured logging system and all was fine. 2-3 weeks later, after many commits one of developers notices that logging goes only to server.log file of wildfly and not to configured log. Configured log in empty. Again - the logging configuration was not changed. What could it be?
pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.19</version>
<scope>${artefact.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.5</version>
<scope>${artefact.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>
<scope>${artefact.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
<scope>${artefact.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.5</version>
<scope>${artefact.scope}</scope>
</dependency>
jboss-deployment-structure.xml
<deployment>
<dependencies>
<module name="org.jboss.ironjacamar.jdbcadapters" />
<module name="org.postgres" />
</dependencies>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
<exclude-subsystems>
<subsystem name="logging"/>
</exclude-subsystems>
</deployment>
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace">
<Properties>
<Property name="log-path">${env:LOG_HOME:-/opt/wildfly-10.1.0.Final/standalone/log/}/admin/</Property>
</Properties>
<Appenders>
<Console name="console-log" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %C:%c{1}:%L - %msg%n"/>
</Console>
<RollingFile name="ADMIN" fileName="${log-path}/admin.log"
filePattern="${log-path}/admin-%d{yyyy-MM-dd}.log.gz">
<PatternLayout>
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %C:%c{1}:%L - %msg%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="my.package" level="INFO" additivity="false" includeLocation="true">
<appender-ref ref="ADMIN" level="INFO"/>
<appender-ref ref="console-log" level="DEBUG"/>
</Logger>
</Loggers>
PS. In my server.log I can see this -
15:05:08,007 ERROR [stderr] (ServerService Thread Pool -- 111) SLF4J: Class path contains multiple SLF4J bindings.
15:05:08,007 ERROR [stderr] (ServerService Thread Pool -- 111) SLF4J: Found binding in [vfs:/content/admin-1.0-SNAPSHOT-dev.war/WEB-INF/lib/slf4j-jdk14-1.7.5.jar/org/slf4j/impl/StaticLoggerBinder.class]
15:05:08,008 ERROR [stderr] (ServerService Thread Pool -- 111) SLF4J: Found binding in [vfs:/content/admin-1.0-SNAPSHOT-dev.war/WEB-INF/lib/log4j-slf4j-impl-2.5.jar/org/slf4j/impl/StaticLoggerBinder.class]
15:05:08,008 ERROR [stderr] (ServerService Thread Pool -- 111) SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
15:05:08,009 ERROR [stderr] (ServerService Thread Pool -- 111) SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
The thing is - file is created, but it is empty. Any ideas?
Thank you.
You have to resolve the conflict between the dependencies. You could use use mvn dependency:tree to identify dependencies then remove or exclude them.
From the server log : StaticLoggerBinder.class loaded from log4j-slf4j and slf4j-jdk14 and it is conflicting. So you could exclude slf4j-jdk14 library and try. Further about multiple binding
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.