Log4php how to append new loggers / appenders to existing Logger class?

I run a php project with several plugins, each of them using Log4php.
I want each plugin to use its own log4php instance and configuration if the plugin is running alone, but i also want them to share (or to implements several instances if possible) a Logger configuration, each plugin appending its own configuration (basically an appender with file and logger).

At the moment, each plugin has a function similar to the following, but it seems that the first plugin activated receives all log messages in its file…
And when i desactivate the first plugin, then the second starts logging… like if the configuration could not be shared.
can you please help ?

Logger::configure ( array (
                    'rootLogger' => array (
                            'appenders' => array (
                                    'gfcr_default'
                            ),
                            'level' => 'debug'
                    ),
                    'appenders' => array (
                            'gfcr_default' => array (
                                    'class' => 'LoggerAppenderDailyFile',
                                    'layout' => array (
                                            'class' => 'LoggerLayoutPattern',
                                            'params' => array (
                                                    'conversionPattern' => "%date{Y-m-d H:i:s,u} %logger %-5level %F{10}:%L %msg%n"
                                            )
                                    )
                                    ,

                                    'params' => array (
                                            'file' => strval ( $logFilesPath ),
                                            'append' => true,
                                            'datePattern' => "Y-m-d"
                                    )
                            )
                    )
            ) );

Read more here: Log4php how to append new loggers / appenders to existing Logger class?

Leave a Reply

Your email address will not be published. Required fields are marked *