Skip to content
PHP library to send logs to
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Logger Added application parameter Jan 14, 2017
LICENSE Fixed README Jan 14, 2017

PHP Logger

PHP library to send realtime logs to, an ELK as a service.


Install with composer:

$ composer require vagnercsouza/logger


First of all, you need an account on Then, go to you profile settings and get your api key (token).


To configure the library, you just need to get an instance of Logger and set the api key. You need to do it once:


You can eather set an application name to identify the logs if you have more than one app sending logs:

\Logger\Logger::getInstance()->setApplication('My App Name');

Sending logs

To send a log, you need to get an instance of Logger and use one of the following functions:

// Send an info log
\Logger\Logger::getInstance()->info('My info log');

// Send a warning log
\Logger\Logger::getInstance()->warning('My warning log');

// Send an error log
\Logger\Logger::getInstance()->error('My error log');

// Send a debug log
\Logger\Logger::getInstance()->debug('My debug log');

Sending multiple logs

By default, the log is delivered to right after you call the info, warning, error or debug functions. If you need to deliver more than one log, you can enable the bulk option, which will wait until you call the send function to actually deliver the logs to

// Enable the bulk mode

// Send as many logs as you want
\Logger\Logger::getInstance()->warning('My warning log');
\Logger\Logger::getInstance()->error('My error log');
\Logger\Logger::getInstance()->warning('My second warning log');

// Finally, deliver the logs to

Sending parameters

If you need to send parameters with the log, you just need to pass an array as second parameter of the logs functions:

// Send an info log
\Logger\Logger::getInstance()->info('My info log', ['user' => 1213]);

// Send a warning log
\Logger\Logger::getInstance()->warning('My warning log', ['foo' => 'bar']);

// Send an error log
\Logger\Logger::getInstance()->error('My error log', ['line' => 18]);

// Send a debug log
\Logger\Logger::getInstance()->debug('My debug log', ['foo' => 'bar']);


To contribute, create a fork, make your changes, make tests, test and create a PR.


This library is licenced under MIT.

You can’t perform that action at this time.