简体   繁体   中英

php setting an error log

I'm having a hard time forcing my application to log errors. Here is a file hierarchy:

/opt
  +-lampp
      +-htdocs
        +-project
          +-app
          | +-config
          | | +-errors.php
          | +-controllers
          | +-log
          | | +-error.log
          | +-etc...
          | +-index.php
          +-pub

And here is the errors.php :

<?php
/*
 * This is configuration for error handling
 */

ini_set('safe_mode','off');
//to display errors in browser, set 1
ini_set('display_errors',1);
//to write errors to a  log file, set 1
ini_set('log_errors',1);
//set default file to log errors
ini_set('error_log','app/log/error.log');
//error reporting level, set to E_ALL to see all errors and notices
//error_reporting(E_ALL);
error_reporting(E_ERROR|
        E_WARNING|
        E_CORE_ERROR|
        E_CORE_WARNING|
        E_COMPILE_ERROR|
        E_COMPILE_WARNING|
        E_USER_ERROR|
        E_USER_WARNING|
        E_STRICT|
        E_RECOVERABLE_ERROR|
        E_DEPRECATED|
        E_USER_DEPRECATED);
error_log('hi');

I read in some article that this might be caused by the safe mode, so i turned it of, but it changed nothing.

Also have an idea that my path might be wrong, in that case, what should it be?

I realise that this question was asked before, but i have already read these articles and they didn't helped me. Even though this is a kind of a "debug my code" question, could someone help me?

(ps im sure the error.php file was reached and executed.) (pps error.php is included in index.php)

EDIT:

So i commented the safe mode line and dumped these lines:

error_reporting => int(22527)

error_log => bool(true)

Thank you for the posts, i learned quite a couple of things from them. When i tried the absolute path i learned that the problem is in file rights. All i had to do is

sudo chmod 777 error.log

Anyway, is it a good idea to have a file with 777 rights in your project directory?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM