to send logs from php application to graylog using monolog

Viewed 7794

I have installed graylog server and its dependencies.Trying to send logs from my php application to graylog server using Monolog. But I am not aware of how to use the Gelf handler.I have seen the GelfHandlerTest.php that is present inside the project Monolog but I am not able to set my publisher and create the handler.Can please anybody explain me with a sample code how to use it.

Trying to send logs from my localhost apache to a server that is set up in the same private network where the graylog is installed.

The testLogging file that is getting executed in PHP are,

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\GelfHandler;
use Gelf\Message;
use Monolog\Formatter\GelfMessageFormatter;


$handler = new GelfHandler($publisher);

How to set the publisher in monolog?

Any sort of help is appreciated.Thanks

1 Answers
Related