Search code examples
phplogginglog4php

Log4php wrong time


I'm a new user of log4php and I have a problem with the time. The time logged in the log file is late of 2 hours compared with the real time. My configuration file contains:

< layout class="LoggerLayoutPattern"> < param name="conversionPattern" value="%-5level %date{Y-m-d H:i:s,u} %logger %msg%n" /> < /layout>

My configuration:

  • apache-log4php-2.3.0
  • WampServer 2.4 -x64
  • windows 7 64 bits

How can I get the correct time ? Thanks for any advice :)


Solution

  • Have you set a timezone in your php script?

    You can set it like:

    date_default_timezone_set('Europe/Amsterdam');
    

    Or you can set it on the server in the php.ini or .htaccess files as shown in the following article. How to set a timezone on your PHP server.