Raj*_*war 6 php logging monolog graylog
我已经安装了graylog服务器及其依赖项。尝试使用Monolog将日志从我的php应用程序发送到graylog服务器。但我不知道如何使用 Gelf 处理程序。我已经看到了 Monolog 项目中存在的 GelfHandlerTest.php,但我无法设置我的发布者并创建处理程序。请任何人用示例代码向我解释一下如何使用它。
尝试将日志从我的本地主机 apache 发送到在安装 Graylog 的同一专用网络中设置的服务器。
在 PHP 中执行的 testLogging 文件是,
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\GelfHandler;
use Gelf\Message;
use Monolog\Formatter\GelfMessageFormatter;
$handler = new GelfHandler($publisher);
Run Code Online (Sandbox Code Playgroud)
monolog中如何设置发布者?
感谢任何形式的帮助。谢谢
请检查以下链接:
https://laracasts.com/discuss/channels/general-discussion/l5-logging-to-graylog2
Graylog2 与 Symfony 2 (Monolog)
基本上你需要类似的东西:
$handler = new GelfHandler(new Gelf\Publisher(
new Gelf\Transport\TcpTransport(HOST,PORT)
));
传输必须是您在grayog平台中添加的输入。例如:
new TcpTransport(127.0.0.1,12201)
可用的传输: https ://github.com/bzikarsky/gelf-php/tree/master/src/Gelf/Transport
希望能帮助到你。