来源于:http://trac.seagullproject.org/wiki/Howto/Logging

日志记录

概述

注意:要使用SGL::logMessage(),你要在Seagull Admin → General → Configuration → Logs打开日志功能

  • 用SGL::logMessage可以详细记录日志或用PHP的error_log()简单记录。
  • 你可以有选择的传递文件或行参数 (如下所示)
  • 你也可以设置优先级 (默认是 PEAR_LOG_INFO),所以PEAR_LOG_DEBUG 消息只会在日志记录设置成debug模式时被记录。
  • 格式是

SGL::logMessage(String $msg[, String $file, Int $line, Constant $priority]);`.

  • 例子:
  SGL::logMessage('I went here', PEAR_LOG_DEBUG);
  SGL::logMessage(null, PEAR_LOG_DEBUG); // Just record date/level/class/function
  SGL::logMessage('Parameter foo is set to  ' . $foo);  // Record at INFO level

注意 CLASSFUNCTION 事实上是被logMessage这个函数自动设置和输出的。

输出样例:

Aug 26 14:50:47 Seagull [debug] sgl_controller→_displaypage:

管理日志文件

提示:如果你正在使用UNIX/LINUX系统,你可以使用logrotate来控制你的日志文件:

Logrotate.conf:
============
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones 
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

在logrotate.d目录内创建一个名为seagull的文件,包含如下内容:

/var/log/php_log.txt {
    missingok
    notifempty
}

查看Howto/DebuggingIdeas获取更多资料。

Comment by aj on Thu Mar 8 15:51:15 2007

注意:在Apache 1.3.x服务器上,如果你的日志文件超过2GB,它将会导致显示空白页面。

 
howto/logging.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2