Yii Framework Forum: YII错误日志能不记录Stack trace吗 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

YII错误日志能不记录Stack trace吗 Rate Topic: -----

#1 User is offline   tamecat 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 30-August 12

Posted 06 September 2012 - 05:04 AM

最近开启了YII的文件日志,发现记录了完整的Stack trace信息,造成日志文件太大,请问怎么能不记录Stack trace呢?

2012/09/06 16:51:08 [error] [exception.CHttpException] exception '.CHttpException' with message '添加失败' in E:\wamp\www\mysite\protected\modules\admin\models\news.php:31
Stack trace:
#0 E:\wamp\www\mysite\protected\modules\setting\controllers\NewsController.php(60): NewsManager->add(Object(News))
#1 E:\wamp\www\mysite\framework\web\actions\CInlineAction.php(50): NewsController->actionAdd()
#2 E:\wamp\www\mysite\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
#3 E:\wamp\www\mysite\framework\web\CController.php(287): CController->runAction(Object(CInlineAction))
#4 E:\wamp\www\mysite\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
#5 E:\wamp\www\mysite\framework\web\CWebApplication.php(276): CController->run('add')
#6 E:\wamp\www\mysite\framework\web\CWebApplication.php(135): CWebApplication->runController('setting/waterma...')
#7 E:\wamp\www\mysite\framework\base\CApplication.php(162): CWebApplication->processRequest()
#8 E:\wamp\www\mysite\index.php(15): CApplication->run()
#9 {main}
REQUEST_URI=/mysite/index.php?r=setting/watermark/add
HTTP_REFERER=http://localhost/mysite/index.php?r=admin/news/index

怎么可以在日志中不记录#0--#9的这堆信息呢?
0

#2 User is offline   riverlet 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 21-August 10
  • Location:Beijing

Posted 11 September 2012 - 06:32 AM

index.php

define('YII_TRACE_LEVEL',0);
0

#3 User is offline   hehbhehb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 24-February 12

Posted 30 September 2012 - 08:57 PM

是有这个问题! 与是否定义'YII_TRACE_LEVEL'无关
在应用中报错本是一种正常逻辑,但是throw new CHttpException()时log中总是会记录一堆信息.
原因是:当throw new CHttpException()时, 会执行到CApplication::handleException(), 这里面有个$message=$exception->__toString(); 这个php自己的Exception::__toString()函数转换后就有这么多信息, 没有办法.

如果实在不想要这么多信息,只好自己重定义一下,如
class CHttpException extends CException
{
...
public function __toString()
{
return $this->getMessage();
}

}
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users