简体   繁体   English

在使用Codeigniter的日志上需要帮助吗?

[英]Need a help on logs with codeigniter?

I have used codeigniter framework.Have used its log part. 我使用了codeigniter框架,使用了它的log部分。 I had a query regarding configuring logs in the application. 我有一个关于在应用程序中配置日志的查询。 As per the documentation they say that we can configure in app/config/php and filter the logs as debug,error or info messages. 根据文档,他们说我们可以在app / config / php中进行配置,并将日志过滤为调试,错误或信息消息。 But even after doing that, I am not able to filter the logs. 但是即使这样做,我也无法过滤日志。 Wanted to know the reason for this or am i missing something. 想知道这个原因还是我错过了一些东西。 Help would be highly appreciated. 帮助将不胜感激。

You need to follow the following steps to keep log file. 您需要按照以下步骤保存日志文件。

  1. Change the following line of your application/config/config.php file 更改application/config/config.php文件的以下行

     $config['log_threshold'] = 4; 

    instead of 代替

     $config['log_threshold'] = 0; 

This change will produce a log file in your application/logs directory with current date as file name. 此更改将在您的application/logs目录中生成一个日志文件,并以当前日期作为文件名。

Now if you want to write your custom log in this log file then write the following code: 现在,如果要在此日志文件中写入自定义日志,请编写以下代码:

log_message('ERROR','YOUR_MESSAGE_HERE');

Here you can use 'ERROR', 'DEBUG' etc. 在这里,您可以使用“ ERROR”,“ DEBUG”等。

Hope this will help you. 希望这会帮助你。

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

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