0

I have this standalone.xml configuration in a subsystem:

<subsystem xmlns="urn:jboss:domain:logging:3.0">
    <console-handler name="CONSOLE">
        <level name="INFO"/>
        <formatter>
            <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
        </formatter>
    </console-handler>
    <periodic-rotating-file-handler name="FILE">
        <formatter>
            <pattern-formatter pattern="%d %-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>
    <periodic-rotating-file-handler name="CMP">
        <formatter>
            <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
        </formatter>
        <file relative-to="jboss.server.log.dir" path="CMP.log"/>
        <suffix value=".yyyy-MM-dd"/>
        <append value="true"/>
    </periodic-rotating-file-handler>
    <logger category="org.hibernate.SQL">
        <level name="DEBUG"/>
        <handlers>
            <handler name="CMP"/>
        </handlers>
    </logger>
    <root-logger>
        <level name="INFO"/>
        <handlers>
            <handler name="CONSOLE"/>
            <handler name="FILE"/>
        </handlers>
    </root-logger>
</subsystem>

When I run the application, it prints the org.hibernate.SQL (SQL queries for example) in both files, but I want to it prints the org.hibernate.SQL only in CMP.log file.

How can I exclude org.hibernate.SQL writes from server.log and print it only in CMP.log file?

dani77
  • 199
  • 2
  • 5
  • 26

1 Answers1

1

You need to set the use-parent-handlers to false on the org.hibernate.SQL logger. With CLI you'd do something like:

/subsystem=logging/logger=org.hibernate.SQL:write-attribute(name=use-parent-handlers, value=false)
James R. Perkins
  • 16,800
  • 44
  • 60
  • Thanks @james-r-perkins. It works. It was the same as disable Use Parent handlers in the console administrative for org.hibernate.SQL. – dani77 Sep 06 '20 at 00:04