LOG4PHPで出力フォーマットを指定しないとログには日時は出力されない
以下はLOG4PHPに渡す設定ファイル(config.xml)の内容
<configuration xmlns="http://logging.apache.org/log4php/"> <appender name="myAppender" class="LoggerAppenderFile"> <param name="file" value="c:/phplog/myLog.log" /> </appender> <root> <appender_ref ref="myAppender" /> </root> </configuration>
設定ファイルを以下に変更して日時を出力指定する
<configuration xmlns="http://logging.apache.org/log4php/"> <appender name="myAppender" class="LoggerAppenderFile"> <layout class="LoggerLayoutPattern"> <param name="conversionPattern" value="%d %-5p %m%n" /> </layout> <param name="file" value="c:/phplog/myLog.log" /> </appender> <root> <appender_ref ref="myAppender" /> </root> </configuration>
すると以下のエラーが表示された
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for '9.0/no DST' instead in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\php\php\log4php\pattern\LoggerPatternConverterDate.php on line 74 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for '9.0/no DST' instead in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\php\php\log4php\pattern\LoggerPatternConverterDate.php on line 74 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for '9.0/no DST' instead in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\php\php\log4php\pattern\LoggerPatternConverterDate.php on line 74 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for '9.0/no DST' instead in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\php\php\log4php\pattern\LoggerPatternConverterDate.php on line 74
メッセージに従ってphp.iniに以下を追加して対応
date.timezone = Asia/Tokyo