1

This is driving me nuts.

I install a clean copy of the latest CodeIgniter (3.1.9) in my Centos-Apache-PHP server (PHP 7.2.6).

Globally, my PHP logs errors to (say) /var/www/logs/php_err.log.

I check that indeed my PHP errors are logged there, including parse errors (PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC)...) , in any non-CI PHP page. It also logs if the parse error happens in a file included in by require_once().

I also check that, inside CI application code (controller or model), it logs there when I call error_log("something");.

I even check that if I purposedly break CI's index.php (adding a asd line after the opening <?php, the parse error appears in my log.

The problem is that a parse error in (say) a controller (say, remove the first brace in application/controllers/Welcome.php ), gives a plain 500 error page, and nothing in the log file.

By changing the environment from productionto development I can see the parse error in the web page. But still nothing in the logs. And, in any case, I definitely want the errors in the logs, also in production!

The problem persists if I comment out the whole "ERROR_REPORTING" block in index.php

Why is this happening?

1 Answer 1

1

By default, Codeigniter uses its own error reporting system. To get errors to log, please take a look in the config.php file under $config['log_threshold'];. There is a definition table above the variable defining what different values equate to but I think $config['log_threshold'] = 1; will work for your purposes (by default it is 0 i.e. off). If you have different folders for production/development then you should modify this variable for both config files. By default, as shown in index.php production errors are suppressed from output via this line: ini_set('display_errors', 0);.

Logs will appear in application/logs/ directory and are organized by Y-m-d H:i:s.

Hopefully this answers your question.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Yeah, the problem was not the default (it was 1, as it should) , but that my apache user had not write permissions on that dir. I feel that that should be mentioned in the installation docs... codeigniter.com/user_guide/installation/index.html
you always need write permissions for that kindof thing but yea, it should probably say "not writable" for such things to give a better understanding of what the error is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.