Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure WildFly 8.2.0 logging to show JUST the application on debug level

Sorry for this very basic question, but I spent a lot of time and research on that and can't get it to work :-/ What I want: Show all loggings on INFO level, but my application on DEBUG level. My setup and understanding so far is:

In my WildFly I am using slf4j with logback. I did not configure logback at all b/c this is done within the WildFly configuration. This my pom:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.13</version>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.0.13</version>
</dependency>

This is my logger configuration:

<console-handler name="CONSOLE">
    <level name="DEBUG"/>
    <formatter>
        <named-formatter name="COLOR-PATTERN"/>
    </formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
    <formatter>
        <named-formatter name="PATTERN"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="server.log"/>
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
    <level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
    <level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
    <level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
    <level name="WARN"/>
</logger>
<logger category="jacorb">
    <level name="WARN"/>
</logger>
<logger category="org.hibernate">
    <level name="INFO"/>
</logger>
<logger category="javax">
    <level name="INFO"/>
</logger>
<logger category="com.sample.application" use-parent-handlers="false">
    <level name="DEBUG"/>
    <handlers>
        <handler name="CONSOLE"/>
    </handlers>
</logger>
<root-logger>
    <level name="DEBUG"/>
    <handlers>
        <handler name="CONSOLE"/>
        <handler name="FILE"/>
    </handlers>
</root-logger>

So the handlers and the root logger must stay on debug, otherwise no debug level log will come through. But then everything else, e.g. [org.jboss.as.controller.management-operation] comes through on debug level as well, and I can't manually set everything to INFO level. Where am I wrong? Thanks in advance!

like image 720
olkoza Avatar asked Jan 06 '23 23:01

olkoza


1 Answers

Leave the console-handler level on DEBUG, change the root-logger level back to INFO, and simply change your application logger to

<logger category="com.sample.application">
    <level name="DEBUG"/>
</logger>
like image 194
Harald Wellmann Avatar answered Jan 14 '23 15:01

Harald Wellmann