php - Syslog : What is the Configuration for Log errors using syslog in my PHP Application

标签 php logging error-handling syslog

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

使用PHP获得SysLog进行了哪些配置?

最佳答案

    // 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

关于php - Syslog : What is the Configuration for Log errors using syslog in my PHP Application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18181029/

相关文章:

javascript - 如何使用两点经纬度绘制行车路线路径

php - 输出 JSON 时网页未加载 PHP-MySQL 代码

Mysql日志表架构

meteor - meteor 中的错误捕获问题

php - 自定义错误处理程序函数中的error_level和error_message来自何处以及如何出现?

javascript - 当我得到 $q 时变量未定义?

php - 具有 WooCommerce 身份验证的 WordPress 自定义 API

python - Django 和 fcgi - 日志记录问题

debugging - `with_items` 输出过于冗长

error-handling - 有没有办法指向 Rust 中发生错误的代码?