How do I log errors and warnings into a file?

前端 未结 7 1378
感动是毒
感动是毒 2020-11-22 04:43

How do I turn on all error and warnings and log them to a file, but to set up all of that within the script (not changing anything in php.ini)?

I want to define a fi

7条回答
  •  误落风尘
    2020-11-22 04:57

    Simply put these codes at top of your PHP/index file:

    error_reporting(E_ALL); // Error/Exception engine, always use E_ALL
    
    ini_set('ignore_repeated_errors', TRUE); // always use TRUE
    
    ini_set('display_errors', FALSE); // Error/Exception display, use FALSE only in production environment or real server. Use TRUE in development environment
    
    ini_set('log_errors', TRUE); // Error/Exception file logging engine.
    ini_set('error_log', 'your/path/to/errors.log'); // Logging file path
    

提交回复
热议问题