wildfly - How to force spring boot to log to the container via SLF4J? -
i have spring boot application running on wildfly 10 wish "force" logging through container. ultimate goal control logging via standalone.xml config having org.springframework.* info level , own code debug level. after many questions , googling best solution achieved is:
- my own code logs correctly , "captured" container.
- spring framework in debug , ignores whatever defined in container root logger.
- org.hibernate.sql in debug , ignores application server.
- i spring auto-configuration report.
my configuration far is:
<!-- handlers , formatters ommited brevity --> <subsystem xmlns="urn:jboss:domain:logging:3.0"> <add-logging-api-dependencies value="true"/> <use-deployment-logging-config value="false"/> <logger category="com.arjuna"> <level name="info"/> </logger> <logger category="org.jboss.as.config"> <level name="info"/> </logger> <logger category="org.jboss.logging" use-parent-handlers="false"> <level name="debug"/> <handlers> <handler name="file"/> </handlers> </logger> <logger category="myapp" use-parent-handlers="false"> <level name="debug"/> <handlers> <handler name="myapp"/> </handlers> </logger> <root-logger> <level name="info"/> <handlers> <handler name="console"/> <handler name="file"/> </handlers> </root-logger> </subsystem>
as pom followed many answers here try , remove trace of spring logback implementations , forcing use sl4j. ideia exclude commons-logging , starter-logging packages every spring-boot-starter.
i ommited packages space, own utility jar's ommit 2 artifacts in own pom's (for each used starter).
<dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> <exclusions> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-tomcat</artifactid> </exclusion> <exclusion> <artifactid>commons-logging</artifactid> <groupid>commons-logging</groupid> </exclusion> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-logging</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-jpa</artifactid> <exclusions> <exclusion> <artifactid>commons-logging</artifactid> <groupid>commons-logging</groupid> </exclusion> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-logging</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-security</artifactid> <exclusions> <exclusion> <artifactid>commons-logging</artifactid> <groupid>commons-logging</groupid> </exclusion> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-logging</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context-support</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-activemq</artifactid> <exclusions> <exclusion> <artifactid>commons-logging</artifactid> <groupid>commons-logging</groupid> </exclusion> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-logging</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>com.jayway.jsonpath</groupid> <artifactid>json-path</artifactid> <scope>test</scope> </dependency> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>javax.servlet-api</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>com.querydsl</groupid> <artifactid>querydsl-apt</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>com.querydsl</groupid> <artifactid>querydsl-jpa</artifactid> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>jcl-over-slf4j</artifactid> </dependency> <dependency> <groupid>net.sf.ehcache</groupid> <artifactid>ehcache</artifactid> </dependency> </dependencies>
also, have tried using jboss-deployment-structure.xml, albeit no avail. current configuration is:
<?xml version="1.0" encoding="utf-8"?> <jboss-deployment-structure> <deployment> <exclude-subsystems> <subsystem name="logging" /> </exclude-subsystems> <exclusions> <module name="org.apache.commons.logging" /> <module name="org.apache.log4j" /> <module name="org.jboss.logging" /> <module name="org.jboss.logging.jul-to-slf4j-stub" /> <module name="org.jboss.logmanager" /> <module name="org.jboss.logmanager.log4j" /> <module name="org.slf4j" /> <module name="org.slf4j.impl" /> </exclusions> </deployment> </jboss-deployment-structure>
i checked final maven build and:
- jcl-over-slf4j present
- slf4-api not present.
- jboss-logging-3.3.1.final present (added via hibernate 5 dependencies)
i think i'm missing obvious can't understand is. might be?
thank you.
Comments
Post a Comment