如何在PHP Codeigner Framework中创建错误日志?错误日志有可能在localhost中创建?
是的,您可以为localhost启用。只需转到applications/config/config.php
并添加
$config['log_threshold'] = 1;
$config['log_path'] = '';// add your path
$config['log_path']=''默认为applications/logs-dir
日志阈值:-
0 = Disables logging, Error logging TURNED OFF
1 = Error Messages (including PHP errors)
2 = Debug Messages
3 = Informational Messages
4 = All Messages
更多信息:-如何在CodeIgniter(PHP)中进行错误日志记录
是的,您可以为本地主机和实时服务器启用错误日志。请按照以下步骤进行操作:
- 在application>config>config.php中,将行183更改为
$config['log_threshold'] = 4;
- 然后运行您的应用程序,您将在applicaiton>logs目录中获得以日期为名称的日志文件
如果您想记录自定义错误,请使用以下语法:
log_message('level', 'message')
其中level
可以是错误、调试、信息等。
PHP有一个内置的错误记录系统。
此文件为php_errors.log
此文件的位置:
Ubuntu:/var/log/php_errors.log
XAMPP(Windows):/xampp/php/logs/php_errors.log
要写入此日志文件,只需调用函数"error_log"。
例如向该文件CCD_ 8写入字符串;
或
CodeIgniter内置了一些错误记录功能。
Make your /application/logs folder writable
In /application/config/config.php set
$config['log_threshold'] = 1;
or use a higher number, depending on how much detail you want in your logs
Use log_message('error', 'Some variable did not contain a value.');
要发送电子邮件,您需要扩展核心CI_Exceptions class method log_exceptions()
。你可以自己做,也可以使用它。更多关于在这里扩展核心的信息
请参阅http://ellislab.com/codeigniter/user-guide/general/errors.html