用户
 找回密码
 入住 CI 中国社区
搜索
查看: 14044|回复: 6
收起左侧

[已解决] 如何使用CI的日志自定义输出?

[复制链接]
发表于 2009-12-22 10:04:38 | 显示全部楼层 |阅读模式
看那个帮助文档。。。看了很久也找不到关于日志信息的输出!

有时候想调试一下~~想在某个点指定输出一些信息。。。。

怎么使用CI里面的log ????

我用$this->load->helper("log");说在help目录没有这个log类

可是library里的log好像也用不了。。。。。求教!!
发表于 2009-12-22 10:19:01 | 显示全部楼层
呵呵,楼主看手册还是不仔细啊。
http://codeigniter.org.cn/user_guide/general/errors.html
 楼主| 发表于 2009-12-22 10:37:41 | 显示全部楼层
呵呵,楼主看手册还是不仔细啊。
Hex 发表于 2009-12-22 10:19


谢谢管理员~~~

可是。。这个我看过呀。。。可是我使用log_message("debug/info","afdsfas");
没有输出呀!!是否需要加载什么类库?

能不能给个简单的例子??或者是否需要设计什么?
config.php 这个是这样。。。

$config['log_path'] = 'system/logs/'.date("Y-m-d");

好像什么东西都没有输出。。。。找不到~~
发表于 2009-12-22 11:23:31 | 显示全部楼层
还是手册没仔细看~
log_message 的后面有一段话,我贴一下。
注意: 确保"logs" 文件夹是可写的,才能准确地将消息写入记录文件中。另外,你必须要设置记录的“threshold“来进行记录。例如通过设置“threshold“,你可以只记录错误类型的消息,而不用记录其他两种。如果你将“threshold“设为0,记录就会被禁止。

而 threshold 是在 config.php 中设置的:
PHP复制代码
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
|       0 = Disables logging, Error logging TURNED OFF
|       1 = Error Messages (including PHP errors)
|       2 = Debug Messages
|       3 = Informational Messages
|       4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/

$config['log_threshold'] = 0;
复制代码


学习一个框架一定要把他的所有关键部件都要看一下,即使记不住也要有个印象。
 楼主| 发表于 2009-12-22 14:03:59 | 显示全部楼层
本帖最后由 格物穷理 于 2009-12-22 14:05 编辑

呵呵。看来要仔细看看~~原来最后部分的threshold就是log_threshold

原来都在config.php设置....

我把log_threshold改成4
而目录是windows下的目录。。。应该是可以写的~~~
但好像在logs这个目录下还是什么都没有。。。。。仍然不解~~~
发表于 2009-12-22 14:23:37 | 显示全部楼层
如果都设置了仍然没东西,那就是你的环境问题了,我这里很正常。
具体就要看 PHP 错误信息了,把源码里所有 @ 都去掉就能看到了。
 楼主| 发表于 2009-12-22 15:04:34 | 显示全部楼层
...ok 我重新弄一个新的CI环境试一下。。。

谢谢 管理员~~

本版积分规则