How To Create Error Logs On 1and1 Shared Hosting

How To Create Error Logs On 1and1 Shared Hosting.

Just copy this script into whatever php file you want to check. It will create a file called errors.csv in whatever directory it’s in and show you the issues you are having.

You could also use an include file to include it on every page of your site.

<?
   error_reporting(0); 
   $old_error_handler = set_error_handler("userErrorHandler");

   function userErrorHandler ($errno, $errmsg, $filename, $linenum,  $vars) 
   {
     $time=date("d M Y H:i:s"); 
     // Get the error type from the error number 
     $errortype = array (1    => "Error",
                         2    => "Warning",
                         4    => "Parsing Error",
                         8    => "Notice",
                         16   => "Core Error",
                         32   => "Core Warning",
                         64   => "Compile Error",
                         128  => "Compile Warning",
                         256  => "User Error",
                         512  => "User Warning",
                         1024 => "User Notice");
      $errlevel=$errortype[$errno];

      //Write error to log file (CSV format) 
      $errfile=fopen("errors.csv","a"); 
      fputs($errfile,"\"$time\",\"$filename: 
      $linenum\",\"($errlevel) $errmsg\"\r\n"); 
      fclose($errfile);

      if($errno!=2 && $errno!=8) {
         //Terminate script if fatal error
         die("A fatal error has occurred. Script execution has been aborted");
      } 
   }
?>
No tag for this post.

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

RSS feed for comments on this post | TrackBack URI for this post
Comments

No comments yet.

Leave a comment

(required)

(required)


Time limit is exhausted. Please reload CAPTCHA.