Changing Log threshold at runtime |
Hi,
I have started getting myself used to CI4 recently. I was reading the manual and I wanted to try and see how I can modify Log threshold setting at runtime. So, I put the following code into index.php after the line that loads the bootstrap.php. PHP Code: config('Config\\Logger')->threshold = 5; Then I did a print_r('Config\\Logger') in my view file to see the Log settings and I got the following: Code: Config\Logger Object So far so good. The new threshold value is set (default threshold value in app/Config/Logger.php is 3). Threshold 5 allows 'error' messages, but the default threshold 3 does not. So, I try log_message('error', 'Some error happened!') to test it, but it does not work. The error message does not go into the log file. If I set the threshold to 5 in the app/Config/Logger.php then the same test works. I am using CI4.rc3 installed via Composer. What am I missing ?
The bootstrap loads the logger before you are setting the log threshold.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
You may consider setting log thresholds in an env variable.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
|
Welcome Guest, Not a member yet? Register Sign In |