log_errors and error_log in php for php.ini

守給你的承諾、 提交于 2020-01-04 18:41:06

问题


I'm troing to change settings in php.ini throu php. My problem is that when there is an error, its not put in to the file error_log.txt, so what am I doing wrong?

This is my code:

// Settings for php.ini
ini_set("session.cookie_httponly", 1);
ini_set("session.cookie_secure", 1);
ini_set('display_errors', 'off');
error_reporting(0);

// errormeddelanden loggas i logs/errorlog.txt 
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/logs/error_log.txt');

回答1:


You can use the function error_log().

A simple example from here would be like

ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );

Then check the log file .you cold see like

tail -f /tmp/php-error.log


来源:https://stackoverflow.com/questions/26700851/log-errors-and-error-log-in-php-for-php-ini

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!