Allow array config params
Can you modify this so that you can use the array config format? Using properties or XML do not allow you to dynamically assign variables from PHP. So for instance, here is a config example from another app: //Logging config $logConfig = array( 'appenders' => array( 'default' => array( 'class' => 'LoggerAppenderRollingFile', 'layout' => array( 'class' => 'LoggerLayoutTTCC', ), 'params' => array( 'file' => BASE_APP_PATH.'log/'.$db.'.log', 'maxFileSize' => '1MB', 'maxBackupIndex' => 5, ), ), ), 'rootLogger' => array( 'level'=>'WARN', 'appenders' => array('default'), ), );
Logger::configure($logConfig);
$log = Logger::getLogger('myLogger')
As you can see, I dynamically assign the log path and file name based on the instance I am using. Also I find this a bit more intuitive. The properties example is mostly there so it remains similar to log4j. Perhaps you can make it an option?
Hi,
You want to use like this?
$this->load->library('log');
$this->load->helper('log4php');
$this->log->configure($logConfig);
log_debug('hoge');
yes that would be perfect (assumed $logConfig is similar to the array I provided as an example).
$ logConfig is setting you need is an array? The path to the configuration file or bad?
I was thinking about that, the array should be what passes so you can dynamically assign vars based on data in the application. Having a static file might not work the same unless you can pass it values.
are going to use as a configuration file or php file is useless? https://logging.apache.org/log4php/docs/configuration.html
I personally need to be able to pass an array that is generated based on my code but being able to get the configs from a file as well would probably be useful and a more commonly needed feature.
Hi,
I pushed branch feature/php_variable_configurator.
Use like this.
$this->load->library('log');
$this->load->helper('log4php');
$this->log->reConfigure($logConfig, 'LoggerConfiguratorPhpVariable');
log_debug('hoge');
$logConfig is look this. https://logging.apache.org/log4php/docs/configuration.html
Once I was fine if you want to merge to master.
Yeah that looks like it would work real well. The one other change request (and I can open a new issue if your prefer), would be to be able to use the installed PEAR version rather than download the entire code for log4php.
Sorry, I changed ci_log4php. because ci_log4php is not original log4php.
Might be useful to figure out a way to use the installed PEAR library but not at all necessary. I am testing the new configs now and I will let you know my results.
Does this use the log level set in the array or the config?
I am not getting any logs created. With or without reConfigure I am not getting any logs being generated.
Sorry for the quad post. So it looks like it is not pulling the path from the array and I am not sure if its pulling any settings. When I had uploaded the new version I overwrote the properties file.
Sorry, I found easy bug. Pushed fixed bug to feature/php_variable_configurator. Please retry.
I am getting a fatal error: Fatal error: Class 'LoggerConfiguratorPhpVariable' not found in /var/www/clients/client0/web13/web/application/third_party/ci_log4php/LoggerReflectionUtils.php on line 132
I get this regardless of whether I use the properties file or the array
Sorry,
Fixed it and pushed.
Hi,I did all operations according to instruction,but I find the code snippet in readme invoke the codeigniter log. $_log =& load_class('Log'); Is this right? I print in the codeigniter Log.php,It do invoke Log.php