Set PHP error log in config.php??

Set PHP error log in config.php??

by Scott Brim -
Number of replies: 2

Greetings and please pardon my newness.

I'm trying to debug a problem with using PHP mail, but every time PHP finishes (and mail fails), my screen is refreshed. I don't have access to the system php.ini so I can't set error_log there. Since I'm not sure which scripts are being called, where can I set where to send debug output? Would it be legitimate to set it in config.php, and if so, is there anything special required?

Right now I'm running a screen recorder and scrolling quickly through the PHP messages, then reviewing the video. tongueout

Thanks ... Scott

Average of ratings: -
In reply to Scott Brim

Re: Set PHP error log in config.php??

by James McLean -

Yes, you can add settings in config.php to override php.ini settings. Needless to say they they'll only apply to Moodle pages - but this sounds like exactly what you're after anyway.

Add the following line to config.php:

@ini_set('log_errors', 'on');
@ini_set('error_log', '/path/to/log/file.log');

Make sure you change the second argument to a valid path, likely the /tmp directory is OK for a short time - watch your disk space so it doesn't fill up.

You could also set some other variables to increase the logging:

@ini_set('error_reporting', E_ALL);

If you're using an opcode cache such as APC or OpCache you will need to either restart the webserver or flush the Moodle cache.

Average of ratings: Useful (1)
In reply to James McLean

Re: Set PHP error log in config.php??

by Scott Brim -

Thanks much for the confirmation. Here we go ...

Scott