Welcome Guest, Not a member yet? Register   Sign In
How can we generate error log file?
#1

[eluser]Zeeshan Rasool[/eluser]
Quote:Guys!very thnx that you have always been very much coopertive wd me.
Here, I want that when an error occured,the error mesg written in error log file.
here, i copy and add this code in my model from PHP manual,
Code:
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
    {
    // timestamp for the error entry
    $dt = date("Y-m-d H:i:s (T)");

    // define an assoc array of error string
    // in reality the only entries we should
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
    // E_USER_WARNING and E_USER_NOTICE
    $errortype = array (
                E_ERROR           => "Error",
                E_WARNING         => "Warning",
                E_PARSE           => "Parsing Error",
                E_NOTICE          => "Notice",
                E_CORE_ERROR      => "Core Error",
                E_CORE_WARNING    => "Core Warning",
                E_COMPILE_ERROR   => "Compile Error",
                E_COMPILE_WARNING => "Compile Warning",
                E_USER_ERROR      => "User Error",
                E_USER_WARNING    => "User Warning",
                E_USER_NOTICE     => "User Notice",
                E_STRICT          => "Runtime Notice"
                );
        // set of errors for which a var trace will be saved
        $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
        
        $err = "<errorentry>\n";
        $err .= "\t<datetime>" . $dt . "</datetime>\n";
        $err .= "\t<errornum>" . $errno . "</errornum>\n";
        $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n";
        $err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
        $err .= "\t[removed]" . $filename . "[removed]\n";
        $err .= "\t[removed]" . $linenum . "[removed]\n";
    
        if (in_array($errno, $user_errors))
            $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n";
        $err .= "</errorentry>\n\n";
        
        // for testing
        // echo $err;
    
        // save to the error log, and e-mail me if there is a critical user error
        error_log($err, 3, "/system/logs/error.log");
        if ($errno == E_USER_ERROR) {
                    mail("[email protected]", "Critical User Error", $err);
            }
}


Also there,


The behaviour of these functions is affected by settings in php.ini.


Table 1. Errors and Logging Configuration Options

[code]Name             Default               Changeable
error_reporting        E_ALL & ~E_NOTICE     PHP_INI_ALL
display_errors          "1"                  PHP_INI_ALL
display_startup_errors "0"                   PHP_INI_ALL
log_errors "0"                               PHP_INI_ALL
log_errors_max_len    "1024"                 PHP_INI_ALL
ignore_repeated_errors "0"                   PHP_INI_ALL
ignore_repeated_source "0"                   pHP_INI_ALL
report_memleaks        "1"                   PHP_INI_ALL
track_errors           "0"                   PHP_INI_ALL
html_errors            "1"                   PHP_INI_ALL
docref_root            ""                    PHP_INI_ALL
docref_ext             ""                    PHP_INI_ALL
error_prepend_string  NULL                   PHP_INI_ALL
error_append_string   NULL                   PHP_INI_ALL
error_log             NULL                   PHP_INI_ALL
warn_plus_overloading NULL                   PHP_INI??

problem is that, where shud i make changing and how an error be passed to that function.
when i call that func. through this code.

Also Here , if upload failed then the 'userErrorHandler' func. called

if(!$this->upload->do_upload($video))
        {    
            $errmsg='error ';
            $filename='/system/logs/error.log';
            $linenum='3';
            $vars='';
            $this->userErrorHandler(2047, $errmsg, $filename, $linenum, $vars);}
no result

plz any one who give some trick or other suggession.
thnx in adv.
#2

[eluser]Zeeshan Rasool[/eluser]
see link,

http://www.php.net/error_reporting
#3

[eluser]Michael Wales[/eluser]
If you leave CodeIgniter's logging on (which you should - great way to create error logs and learn when things go wrong), you could just do:

Code:
log_message(1, 'This is your error message.');
#4

[eluser]Derek Allard[/eluser]
Not directly related, but useful http://derekallard.com/blog/post/error-h...deigniter/.
#5

[eluser]phpworker[/eluser]
Hi All!
For the first I would like to thanks to you all for sharing such nice framework. I am working with it for about 6 months and it is just great Smile

I've read Derek's article he provided above. Interesting article, just what I was looking for, but... I did as you described at the end of the article:

"If you wanted to log your errors, but not display them to screen, then you could set the error_reporting at “0” in the index.php, and your log threshold at 1 or more in the config. "

... and it doesn't work. No PHP error is logged!

Where should I look?




Theme © iAndrew 2016 - Forum software by © MyBB