简体   繁体   English

php.ini中的log_errors和error_log

[英]log_errors and error_log in php for php.ini

I'm troing to change settings in php.ini throu php. 我想通过php更改php.ini中的设置。 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? 我的问题是,发生错误时,不会将其放入文件error_log.txt中,那么我在做什么错呢?

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');

You can use the function error_log() . 您可以使用函数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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP未记录错误log_errors = on,error_log路径存在 - php not logging errors log_errors=on, error_log path exists info.php 显示 log_errors 为 Off 但它在加载的配置文件的 php.ini 中设置为 On - info.php shows log_errors is Off but it is set to be On in the php.ini of Loaded Configuration File 在没有php.ini的情况下设置display_errors = 0和log_errors = 1 - Setting display_errors=0 and log_errors=1 without php.ini PHP Windows 上的错误日志文件格式(php.ini error_log 指令) - PHP Error log file format (php.ini error_log directive) on Windows PHP error_log()未记录到php.ini中指定的文件 - PHP error_log() doesn't log to file specified in php.ini 将 php.ini error_log 和 access_log 定向到标准输出 - Direct php.ini error_log and access_log to stdout PHP错误日志-php.ini的PHP错误的唯一文件 - PHP Error Log - php.ini Unique file for php errors 即使在php.ini中定义了error_log,也没有php错误文件 - no php error file even though error_log is defined in php.ini 如何将PHP error_log设置为php.ini中的主目录? - How do I set the PHP error_log to the home directory in php.ini? 无法让 php.ini 输出 error_log(Wordpress、Debian、OpenLiteSpeed) - Can't get php.ini to output error_log (Wordpress, Debian, OpenLiteSpeed)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM