You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Ivan Habunek (JIRA)" <ji...@apache.org> on 2012/09/11 13:40:08 UTC

[jira] [Closed] (LOG4PHP-187) Logging does not work in shutdown function

     [ https://issues.apache.org/jira/browse/LOG4PHP-187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ivan Habunek closed LOG4PHP-187.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.3.0
         Assignee: Ivan Habunek

Cool. Closing issue.
                
> Logging does not work in shutdown function
> ------------------------------------------
>
>                 Key: LOG4PHP-187
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-187
>             Project: Log4php
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: Linux x86_64 GNU/Linux with PHP 5.4.14,
> Windows 7 with PHP 5.4.6
>            Reporter: Till Heimann
>            Assignee: Ivan Habunek
>             Fix For: 2.3.0
>
>
> 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>
> ---------------------------------------------------------------------
> ******* test.php *******
> <?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>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira