Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jboss 7 logger write the same data to two different files

I have jboss 7.1.1 with the following definition:

<subsystem xmlns="urn:jboss:domain:logging:1.1">
        <console-handler name="CONSOLE">
            <level name="INFO"/>
            <formatter>
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
        </console-handler>
        <periodic-rotating-file-handler name="FILE">
            <formatter>
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="server.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <size-rotating-file-handler name="ACEII">
            <level name="DEBUG"/>
            <formatter>
                <pattern-formatter pattern="%z{utc}%d{dd/MM/yyyy HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="ACEII.log"/>
            <rotate-size value="100K"/>
            <max-backup-index value="10"/>
            <append value="false"/>
        </size-rotating-file-handler>
        <logger category="ace2">
            <level name="DEBUG"/>
            <handlers>
                <handler name="ACEII"/>
            </handlers>
        </logger>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <root-logger>
            <level name="INFO"/>
            <handlers>
                <handler name="CONSOLE"/>
                <handler name="FILE"/>
            </handlers>
        </root-logger>
    </subsystem>

as u can see I have one handler that write to the server.log and the other to ACE2.log. problem is that the ACE2 logs are also written to the server.log, what am i doing wrong ?

like image 611
Tomer Avatar asked Dec 27 '22 03:12

Tomer


2 Answers

I found the answer, just add the use-parent-handlers="false" to your logger:

<logger category="ace2" use-parent-handlers="false">
            <level name="DEBUG"/>
            <handlers>
                <handler name="ACEII"/>
            </handlers>
        </logger>
like image 156
Tomer Avatar answered Dec 30 '22 11:12

Tomer


The FILE handler which writes to server.log is listed in the root logger and thus will receive the messages from the ace2 logger as well.

like image 26
Thomas Avatar answered Dec 30 '22 11:12

Thomas