Graylog engine for CakePHP

Installs: 19 652

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 3

Open Issues: 1


v3.0.0 2021-12-13 17:53 UTC


License: MIT Packagist Version Build Status Maintainability Test Coverage

Graylog log engine for CakePHP 3.x


composer require kba-team/cakephp-graylog
\Cake\Core\Configure::write('Log.graylog', [
    'className' => \kbATeam\CakePhpGraylog\Log\Engine\GraylogLog::class,
    'levels' => [\Psr\Log\LogLevel::EMERGENCY, \Psr\Log\LogLevel::ALERT, \Psr\Log\LogLevel::CRITICAL],
    'host' => 'graylog.example.com',
    'port' => 12201,
    'scheme' => 'udp',
    'facility' => 'MyAppName',
    'append_backtrace' => true,
    'append' => [
        //append the contents of $_POST JSON encoded to the message body
        'POST' => static function () {
             if (!empty($_POST)) {
                $obfuscator = new \kbATeam\GraylogUtilities\Obfuscator();
                //Replace the value of all keys named 'password' with 'xxx'.
                //JSON encode the POST variable for readability.
                return json_encode(
             return null;
    'additional' => [
        //Add field 'current_user' to the GELF message.
        'current_user' => static function () {
             return AuthComponent::user('username');

Possible configuration parameters are:

  • scheme Currently TCP or UDP connections to Graylog are supported. Default: udp
  • host The hostname of the Graylog server. Default:
  • port The port, the Graylog server listens to. Default: 12201
  • url A connection URL in format <scheme>://<host>:<port>. This will overwrite any other settings.
  • ignore_transport_errors Ignore transport errors Default: true
  • chunk_size The size of the UDP packages. Default: \Gelf\Transport\UdpTransport::CHUNK_SIZE_LAN
  • ssl_options An instance of \Gelf\Transport\SslOptions defining SSL settings for TCP connections. Default: null
  • facility The logging facility. Default: CakePHP.
  • append_backtrace Append a backtrace to the message? Default: true
  • append Array of anonymous functions (actually anything that is_callable()). Their return strings get appended to the message body.
  • additional Array of anonymous functions (actually anything that is_callable()). Their return values get added as additional fields to the GELF message.
  • levels Array of log level, that will be sent to Graylog. See \Psr\Log\LogLevel for all possible values. Default: all of them.

Further reading