PHP: Quick tip on setting up server-side logger

October 30, 2007 § Leave a comment

Changes in php.ini:

  1. Around line:416: uncomment error_log variable, and assign it to your prefered logfile.txt. For example, on Windows box: error_log = “C:\log.txt”. Beware: make sure that PHP has permission to modify the log file on *NIX system.
  2. If you want to NOT displaying PHP error on the screen: Around line 360, make sure that: display_errors = off

Grunt work required to make sure that things are logged properly:

use if block:
if(something->bad->going->to->happen)
{
//call this system function
error_log(‘the message why this is bad’);
}

use try catch:
try
{
//do something that’s possibly bad
}
catch(Exception $e)
{
error_log(‘Exception thrown: ‘.$e->getMessage());
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading PHP: Quick tip on setting up server-side logger at RAPD.

meta

%d bloggers like this: