urmaul / yii-formattedfilelogroute

该日志路由扩展了 CFileLogRoute,并允许您指定日志格式。

v1.1.0 2016-01-11 11:26 UTC

This package is not auto-updated.

Last update: 2024-09-24 01:22:51 UTC


README

此日志路由扩展了 CFileLogRoute 并允许您指定日志格式。

如何附加

将路由配置添加到日志路由中。它看起来像这样

array(
	'class'      => 'ext.formattedfilelogroute.FormattedFileLogRoute',
	'format'     => "{time}\t{ip}\t{msg}",
	'categories' => 'application',
	'logFile'    => 'formatted.log',
),

日志变量

您可以在日志格式中使用这些变量

  • {ip} - 客户端 IP
  • {uri} - 请求 URI
  • {ref} - 请求来源
  • {sref} - 短请求来源(如果来源域名是当前域名,则移除域名)
  • {time} - 当前时间
  • {level} - 日志消息级别
  • {category} - 日志消息类别
  • {message} - 完整的日志消息文本
  • {msg} - 无堆栈跟踪的日志消息文本
  • {trace} - 堆栈跟踪

建议的路线

array(
	'class'   => 'ext.formattedfilelogroute.FormattedFileLogRoute',
	'format'  => "{time}\t{ip}\t{category}\t{uri}\t{message}",
	'except'  => 'exception.CHttpException.404',
	'levels'  => 'error',
	'logFile' => 'error.log',
),
array(
	'class'      => 'ext.formattedfilelogroute.FormattedFileLogRoute',
	'format'     => "{time}\t{ip}\t{uri}\t{sref}",
	'categories' => 'exception.CHttpException.404',
	'logFile'    => 'error404.log',
),