Welcome Guest, Not a member yet? Register   Sign In
[INFO] Log errors to PHP error log
#1

I was looking for a possibility to log all CI errors into ordinary PHP log file (domain related in my case). But there was no such, i could just enable CI error logger, but that was not what i wanted, because of log analyzing and cleanup tasks. I wanted definitely get them as PHP errors.

So, that small piece of code do the magic. Create it as MY_Log.php under application/core/
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
MY_Log extends CI_Log {

 
 public function write_log($level$msg) {
 
   if($level == 'error') {
 
     error_log($msg);
 
   }
 
   return parent::write_log($level$msg);
 
 }


So, that's it. It will log all errors as PHP errors in your PHP log file. Hope you like it! Blush
Reply


Messages In This Thread
[INFO] Log errors to PHP error log - by V I R U S - 06-20-2016, 08:34 AM
RE: [INFO] Log errors to PHP error log - by PaulD - 06-20-2016, 09:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB