2

In a java program, I am using log4j2 for my (debug) output. When using a third party libary, I would like to disable the log output from these libraries. How can I do that?

Actually this seems quite simple to me but I could not find a solution for it. I can't be the only one looking for this?

Malhelo
  • 399
  • 6
  • 16

2 Answers2

5

An example of turning off logging in log4j 1.x was to add the following xml tag into log4j.xml. The category name is the package path to the root of the library you want to ignore logging from. For example to ignore log4j logging from the apache tiles library you would use the following:

<category name="org.apache.tiles">
   <priority value = "off" />
</category>    
Mark Carpenter
  • 433
  • 3
  • 9
  • According to the migration manual (http://logging.apache.org/log4j/2.x/manual/migration.html) this would result in `` which seems to do what I asked for. Unfortunately, the library I wanted to shut up seems to be using some other means of logging, but your answer should be right. – Malhelo Jun 02 '14 at 14:50
0

I am using log4j on spring boot, this is my log4j2-spring.xml. I disabled org.apache.poi with this syntax

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>

   ...

    <Loggers>

        <Logger name="org.apache.poi" level="off"/>
        <Root level="info">
            <AppenderRef>
                <ref>${CONSOLE}</ref>
            </AppenderRef>
            <AppenderRef>
                <ref>${SPLUNK}</ref>
            </AppenderRef>
        </Root>
    </Loggers>

</Configuration>
BabyishTank
  • 1,329
  • 3
  • 18
  • 39