0

When trying to use LoggerLayoutPattern, the logger uses the Simple Layout for logging.

log4php.properties

log4php.logger.JsonLogger=DEBUG,JsonLog
log4php.appender.JsonLog=LoggerAppenderDailyFile
log4php.appender.JsonLog.layout=LoggerLayoutPattern
log4php.appender.JsonLog.layout.conversionPattern={error_type:%p, date:%d{d/m/Y}, time: %d{H:i:s:u}, unix_timestamp: %d{U}, logger: %c, process: %t, origin: %server{REMOTE_ADDR}, details: %msg}
log4php.appender.JsonLog.file="D:/logs/log_json_%s.log"

usage:

$logger = LoggerManager::getLogger('JsonLogger');
$logger->debug("Hello");

output:

DEBUG - Hello

What am I doing wrong? Please help.

abhinav
  • 3,199
  • 2
  • 21
  • 25
  • Just a guess: try this (remove the outer curly braces): log4php.appender.JsonLog.layout.conversionPattern=error_type:%p, date:%d{d/m/Y}, time: %d{H:i:s:u}, unix_timestamp: %d{U}, logger: %c, process: %t, origin: %server{REMOTE_ADDR}, details: %msg – DwB Jun 24 '13 at 14:31
  • Which version are you using? Have you considered that the `.properties` file format for configuration has been removed from current log4php versions? The best way IMO is to use a PHP array configuration, which benefits from opcode caches and avoids XML. – Sven Jun 25 '13 at 00:51
  • I'm using v 2.0. Unfortunately, I am not at liberty to change the version or the format of configuration. I have to work with this. – abhinav Jun 25 '13 at 05:35
  • Is there anyway I can get a hold of the v2.0 documentation? I believe, some variables and config parameters were different then. Is it not so? – abhinav Jun 25 '13 at 05:37

0 Answers0