Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.1
-
None
-
None
-
Linux x86_64 GNU/Linux with PHP 5.4.14,
Windows 7 with PHP 5.4.6
Description
I register a shutdown function in php. In this shutdown function I try to log something unsing Log4php.
actual:
No Log entries for any log call within the shutdown function.
expected:
Log entries from the shutdown function.
Exemple Code, config file and shell output:
-
-
-
-
-
- log4php_conf.xml *******
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://logging.apache.org/log4php/">
<appender name="myAppender" class="LoggerAppenderFile">
<layout class="LoggerLayoutTTCC" />
<param name="file" value="test.log" />
</appender>
<root>
<level value="TRACE" />
<appender_ref ref="myAppender" />
</root>
</configuration>
- log4php_conf.xml *******
-
-
-
-
---------------------------------------------------------------------
-
-
-
-
-
-
- test.php *******
<?php
- test.php *******
-
-
-
-
-
require_once './log4php/Logger.php';
Logger::configure('./log4php_conf.xml');
$logger = Logger::getLogger("ShutdownTest");
main();
function main() {
global $logger;
$logger->trace("function main() called");
$logger->info("*** start shutdown test ***");
register_shutdown_function('shutdown');
print("\ndo something ... ");
sleep(1);
print("done\n");
}
function shutdown(){
global $logger;
$logger->trace("function shutdown() called");
// do some stuff like logging errors ...
$logger->info("*** exiting shutdown test ***");
print("This line is printed out.\n");
}
?>
---------------------------------------------------------------------
Linux output:
-bash-3.2$ php test.php
do something ... done
This line is printed out.
-bash-3.2$ cat test.log
Tue Sep 4 14:40:46 2012,948 [29482] TRACE ShutdownTest - function main() called
Tue Sep 4 14:40:46 2012,952 [29482] INFO ShutdownTest - *** start shutdown test ***
-bash-3.2$ php --version
PHP 5.2.14 (cli) (built: Aug 27 2010 16:44:17)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
---------------------------------------------------------------------
Windows output:
PS C:\test_log4php> php .\test.php
do something ... done
This line is printed out.
PS C:\test_log4php> cat .\test.log
09/04/12 14:13:05,118 [4844] TRACE ShutdownTest - function main() called
09/04/12 14:13:05,120 [4844] INFO ShutdownTest - *** start shutdown test ***
PS C:\test_log4php> php --version
PHP 5.4.6 (cli) (built: Aug 15 2012 21:16:03)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
PS C:\test_log4php>