jira handler for monolog

0.3.0 2019-02-26 15:11 UTC

This package is auto-updated.

Last update: 2020-06-26 18:16:00 UTC


Build Status Scrutinizer Quality Score Scrutinizer Coverage Latest Release MIT License Total Downloads

Developed by ARTACK WebLab GmbH in Zurich, Switzerland.


This handler will write the logs to a JIRA instance. The handler will calculate a hash over the log-data except time sensitive data. It then will query the JIRA REST API to determe if there is already a JIRA Issue with the corresponding hash. If so, the handler will do nothing. If there is no issue matching the hash the handler will create a new issue with the content of the log entry.


You can install it through Composer:

$ composer require artack/monolog-jira-handler


With this setup each log entry is transmitted to JIRA.


$jiraHandler = new JiraHandler('', 'username', 'password', 'project = MYAPP AND resolution = Unresolved', 'Loghash', 'MYAPP', 'Bug', true, 'Logcount');

$loger = new Logger('name');

$loger->error('something went wrong...');

If there are several log entries, it makes more sense to buffer the log entries first and transfer them all to JIRA in one step.


$jiraHandler = new JiraHandler('', 'username', 'password', 'project = MYAPP AND resolution = Unresolved', 'Loghash', 'MYAPP', 'Bug', true, 'Logcount');
$bufferHandler = new \Monolog\Handler\BufferHandler($jiraHandler);
$fingersCrossedHandler = new \Monolog\Handler\FingersCrossedHandler($bufferHandler);

$loger = new Logger('name');

// log records
$loger->info('I am somehow nice to know');
$loger->error('something went wrong...');

In a Symfony project

The use of this custom handler in a Symfony project is easy. First configure the JiraHandler as a service.

# config/services.yaml

    # ...

            - ''
            - 'username'
            - 'password'
            - 'project = MYAPP AND resolution = Unresolved'
            - 'Loghash'
            - 'MYAPP'
            - 'Bug
            - true
            - 'Logcount'

Secondly register your configured service as a monolog handler.

# config/packages/{dev|prod|...}/monolog.yaml

            type: fingers_crossed
            action_level: error
            handler: grouped
                # regex: exclude all 404 errors from the logs
                - ^/
            type: group
            members: [stream, buffer]
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            type: buffer
            handler: jira
            type: service
            id: Artack\Monolog\JiraHandler\JiraHandler
        # more handlers as you wish ...

Handler configuration

The JiraHandler has several constructor arguments:

  • $hostname: The hostname of your JIRA instance without the protocol (https:// is enforced).
  • $username: The username under which the issues are created (and any other operation on the JIRA REST API is performed).
  • $password: The password to authenticate against your JIRA instance
  • $jql: The JQL which is used to check if there is already an existing issue regarding the currently processed log entry. This allows to log the very same error on different php projects which will create an issue in a different JIRA project.
  • $hashFieldName: The name of the custom field which will store the md5 hash of the log entry
  • $projectKey: The project key under which a new issue will be created
  • $issueTypeName: The issue type which the new issue will use while being created
  • $withComments: (default: false) Determines if subsequent same (same hash) log entries will be added as comments to the already created issue
  • $counterFieldName: (default: null) If set this is the name of the custom field containing the number of recorded log entries
  • $httpClient: (default: null) The HTTP Client which is used to talk to the JIRA REST API. Any HTTPlug client implementation is allowed. If not specified it will try to autodiscover a suitable client.


This library is licensed under the MIT License - see the LICENSE file for details