【问题标题】:Syslog: What is the Configuration for Log errors using syslog in my PHP ApplicationSyslog:在我的 PHP 应用程序中使用 syslog 记录错误的配置是什么
【发布时间】:2013-08-12 06:49:16
【问题描述】:

如何在 Windows 中为我的 PHP 应用程序配置 Syslog?我有 Surferd in Internet Shows 许多服务器需要安装。

使用 PHP 获取 SysLog 做了哪些配置?

【问题讨论】:

  • PHP 默认函数 bool syslog ( int $priority , string $message ) 仅记录 Windows 默认事件查看器上显示的错误、警告,而不配置 php.ini 文件中的任何更改

标签: php logging error-handling syslog


【解决方案1】:
    // open syslog, include the process ID and also send
// the log to standard error, and use a user defined
// logging mechanism
openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);

// some code

if (authorized_client()) {
    // do something
} else {
    // unauthorized client!
    // log the attempt
    $access = date("Y/m/d H:i:s");
    syslog(LOG_WARNING, "Unauthorized client: $access {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})");
}

closelog();

更多信息请查看http://php.net/manual/en/function.syslog.php

【讨论】:

  • 我需要在哪里放置“myScriptLog”文件它的配置是什么??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-12
  • 1970-01-01
  • 2011-04-27
相关资源
最近更新 更多