Welcome Guest, Not a member yet? Register   Sign In
change config['log_path'] on the fly

I am trying to specify my log directory from MY_Controller (my base class for application/controllers/*.php) depending on the controller class being called. The clog directory was specified using 

in the MY_Controller::__construct(). I have a custom log function in MY_Controller::log() which in turn calls CI's log_message().
All the possible log directories exists and have permission of 777. 


 always return the correct expected log directory.
The issue despite the default log directory being changed successfully to another directory, the string to be logged is being logged into the default log directory (application/logs).
Any help will be appreciated. Thanks.

(This post was last modified: 03-01-2018, 06:18 AM by InsiteFX.)

Try this, it may need to be put into the CodeIgniter global space.

PHP Code:
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

This directive is not supposed to be changed at runtime, and you shouldn't try to.
Quite a lot of messages are logged before you ever have the chance to try altering the path.

(03-01-2018, 06:17 AM)InsiteFX Wrote: Try this, it may need to be put into the CodeIgniter global space.

PHP Code:

... and this cannot possibly help, in any situation. Totally unrelated.

I've lost count of how many times I've had to correct you for stuff like this, @InsiteFX. I know you're trying to help, but you can't just throw random suggestions, because when they don't work, you're doing the very opposite - people waste time with it and are often put in an entirely wrong direction.

Thanks @Narf. Is there a way through which the log directory can be made dynamic? I am of the opinion that this should be possible.

No. I don't understand why you should it should be possible, but even if we wanted to modify the entire framework to allow this, we'd probably still fall short.

OK. Narf, does this apply to "log_path" alone or all CI config params? 

CI gave room for config params modification using
PHP Code:
obviously because those config params can be modified. Also, there is no documentation specifying any config params which can not be changed. This is why i am of the opinion that it should/could be possible.

A few other ones have the same limitation, but it's very far from all of them.

It's very simple - some directives just have to go into effect before you ever have the chance to try modifying them (if you do at all; there's no guarantee that a controller will be instantiated).

All right. Thanks for your time.

Theme © iAndrew 2016 - Forum software by © MyBB