syslog发送到特定的Linux日志文件

syslog发送到特定的Linux日志文件

本文介绍了将PHP syslog发送到特定的Linux日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP 5.5.14运行Centos/Apache,并且正在使用syslog如下写入日志文件:

I am running Centos/Apache with PHP 5.5.14, and am using syslog to write to a log file as follows:

syslog(LOG_INFO,'Some message');

正在将日志写入/var/log/messages并看起来像Aug 10 15:48:16 devserver httpd: Some message,但是,日志文件中还杂乱堆着一堆看起来像Aug 10 15:48:21 devserver kernel: usb 1-1.2: USB disconnect, device number 83的日志.

The logs are being written to /var/log/messages and look like Aug 10 15:48:16 devserver httpd: Some message, however, the log file is also cluttered with a bunch of logs that look like Aug 10 15:48:21 devserver kernel: usb 1-1.2: USB disconnect, device number 83.

如何使PHP将日志发送到其专用日志文件中?

How do make PHP sent logs to its own dedicated log file?

推荐答案

在调用函数 syslog ,则应调用 openlog 并指定"syslog标记".在此框架下,消息将被标记,您可以使用系统记录器(rsyslog,syslog-ng等)将这些消息发送到特定的日志文件,将它们发送到特定的日志服务器,发送紧急消息的电子邮件,等

Before calling the function syslog, you should call openlog and specify the "syslog tag". With this framework, the messages are tagged and you can use the system logger (rsyslog, syslog-ng, etc.) to send these messages to a specific log file, send them to a specific log server, send an email for emergency messages, etc.

博客文章将syslog用于您的php应用程序".详细介绍了如何设置整个程序.

This blog post "Using syslog for your php applications" gives more details on how to setup the whole thing.

这篇关于将PHP syslog发送到特定的Linux日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:03