i have a problem configuring log4php and i don't know where to check on the documentation. I have this config:
Logger::configure(array(
'rootLogger' => array(
'level' => 'INFO',
'appenders' => array('info'),
),
'loggers' => array(
'debug' => array(
'level' => 'DEBUG',
'appenders' => array('debug'),
'additivity' => false
),
'error' => array(
'level' => 'ERROR',
'appenders' => array('error'),
'additivity' => false
)
),
'appenders' => array(
'info' => array(
'class' => 'LoggerAppenderDailyFile',
'layout' => array(
'class' => 'LoggerLayoutPattern',
'params' => array(
'conversionPattern' => '%date %logger %-5level %msg%n'
)
),
'params' => array(
'datePattern' => 'Y-m-d',
'file' => '../log/ilias-info-%s.log',
'append' => true
),
'filters' => array(
'class' => 'LoggerFilterLevelRange',
'params' => array(
'levelMin' => 'info',
'levelMax' => 'info',
)
)
),
'debug' => array(
'class' => 'LoggerAppenderDailyFile',
'layout' => array(
'class' => 'LoggerLayoutPattern',
'params' => array(
'conversionPattern' => '%date %logger %-5level %msg%n'
)
),
'params' => array(
'datePattern' => 'Y-m-d',
'file' => '../log/ilias-debug-%s.log',
'append' => true
),
'filters' => array(
'class' => 'LoggerFilterLevelRange',
'params' => array(
'levelMin' => 'debug',
'levelMax' => 'debug',
)
)
),
'error' => array(
'class' => 'LoggerAppenderDailyFile',
'layout' => array(
'class' => 'LoggerLayoutPattern',
'params' => array(
'conversionPattern' => '%date %logger %-5level %msg%n'
)
),
'params' => array(
'datePattern' => 'Y-m-d',
'file' => '../log/ilias-error-%s.log',
'append' => true
),
'filters' => array(
'class' => 'LoggerFilterLevelRange',
'params' => array(
'levelMin' => 'error',
'levelMax' => 'error',
)
)
)
)
));
Usage: I define once the
$logger = Logger::getLogger(basename(__FILE__));
and then i log what i need like so:
$logger->info("INFO");
$logger->debug("DEBUG");
$logger->error("ERROR");
but only info's log file is created. I used the PHP way to configure the logger because for me it seems to be the easiest way to do it, but there isn't a lot of documentations about this way of doing the conf. What am i doing wrong?
well, it took me awhile to get it to work too. my current config works:
To use this
This is the version i compose into the app