Jump to content

[SOLVED] trigger_error vs. error_log


mottwsc

Recommended Posts

I'm using php5 on linux and do not want to send any error messages to the user but instead to a log file.  Which is better in general for this purpose: trigger_error or error_log?

 

In certain cases, I'll also send an email notification on error.  For this, I'll use error_log.  Is this the best way to do this?

 

Thanks!

 

Link to comment
Share on other sites

  • 7 years later...

I know it's old, but I could not myself from making a comment. To say that error_log and trigger_error have completely different purposes and that the question made no sense is what made no sense. The question made perfect sense. Both uses the php ini directive error_log that sets a log file location, defaulting to the web server log if no value is set in error_log. So, they certainly have a related purpose. One  difference is that the error_log function will perform its duties regardless of the value set in the log_errors ini setting. It does not raise a PHP error, so it does not have a severity level. So, you have more control with trigger_error, but one might want to bypass this control and directly send to the log_error destination without raising a PHP error or warning, etc.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.