log4php not honouring logger levels

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

log4php not honouring logger levels

Javier Urien

   I am trying to use log4php and having a problems understanding the configuration, I am comparing the behaviour from a log4j xml to a log4php xml that are the same. The same code. But with different outputs. From the documentation I would expect 5 lines to be logged, but in the log4php, only one is.
  Please, I am driving myself crazy.

PHP code:




$rlogger = Logger::getRootLogger();
$rlogger->debug('Not logged');

$logger = Logger::getLogger('com.suri');

$logger = Logger::getLogger('com.suri.factory');
$logger->debug('Not logged');

$logger = Logger::getLogger('com.suri.factory.Bar');
$logger->debug('Not logged');


XML config:

<?xml version="1.0" encoding="UTF-8" ?>
<configuration xmlns="http://logging.apache.org/log4php/">
  <!-- A1 is set to be a ConsoleAppender -->
  <appender name="A1" class="LoggerAppenderConsole">
    <layout class="LoggerLayoutPattern">
      <param name="ConversionPattern" value="%d [%t] - %-5p %c - %m%n"/> 
  <logger name="com.suri.factory.Bar">
    <level value="info"/> 
  <logger name="com.suri.factory">
    <level value="warn"/>

  <logger name="com">
    <level value="debug"/>
    <level value="error" />
    <appender-ref ref="A1" /> 


2014-03-13T18:01:30-03:00 [14939] - ERROR root - Logged

Expected Output:
2014-03-13 18:09:03,591 [main] - ERROR root - Logged
2014-03-13 18:09:03,592 [main] - DEBUG com.suri - Logged
2014-03-13 18:09:03,592 [main] - WARN  com.suri - Logged
2014-03-13 18:09:03,592 [main] - WARN  com.suri.factory - Logged
2014-03-13 18:09:03,592 [main] - INFO  com.suri.factory.Bar - Logged


        Ing. Javier Eduardo Urien
SUR Emprendimientos Tecnológicos

Perú 345  Piso 5to Oficina "B" / 8vo Oficina "A" (C1067AAG)
Ciudad de Buenos Aires, Argentina
Tel. +54 (11) 4342-2976/84
[hidden email]