1

I have an application that uses log4cxx internally, with dozens of loggers. What is a minimal logger.properties that I can setup to turn off all logging output?

In particular I'm getting a warning like (no properties file present):

log4cxx: No appender could be found for logger (FileSource).
log4cxx: Please initialize the log4cxx system properly.

FileSource is a class that uses log4cxx.

My goal is to preclude all log4cxx output at runtime.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Dave
  • 7,555
  • 8
  • 46
  • 88

1 Answers1

1

This should do it:

<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <root>
        <priority value="OFF" />
  </root>
</log4j:configuration>

A simple logger.properties that logs to standard out could look like below:

<?xml version="1.0" encoding="UTF-8" ?>
<!-- add attribute  debug="true" to log4j:configuration tag to see how logger reads it's configuration. -->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p %c (%F:%M:%L) - %m%n" />
    </layout>
  </appender>
  <root>
        <priority value="DEBUG" />
        <appender-ref ref="ConsoleAppender"/>
  </root>
</log4j:configuration>
Samuel Åslund
  • 2,814
  • 2
  • 18
  • 23