Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyslogUdpHandler - Allow setting "ident" parameter #266

Closed
dhirtzbruch opened this issue May 5, 2018 · 0 comments
Closed

SyslogUdpHandler - Allow setting "ident" parameter #266

dhirtzbruch opened this issue May 5, 2018 · 0 comments
Labels
Milestone

Comments

@dhirtzbruch
Copy link
Contributor

dhirtzbruch commented May 5, 2018

The SyslogUdpHandler constructor has a sixth parameter "ident", defaulting to "php".
However, the current Monolog Bundle implementation allows setting only the first five. Which defaults to the "ident" being set to "php".
In our case, we are using papertrail as a log backend, and use the same webserver for multiple small projects. In papertrail, that results in the following output:

May 05 02:16:30 vagrant php:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env1.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env1.dev.local/login","level":"critical"} []
May 05 02:18:32 vagrant php:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env2.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env2.dev.local/login","level":"critical"} []

The "php" after "vagrant" is the ident configuration. As you can see, we are not able to determine the source environment, other than guessing from filepath or uri.
However, for filtering using the API, we`d like to be able to change the ident per configuration.

monolog:
    handlers:
        syslog:
            type: syslogudp
            host: example.com
            port: 514
            level: error
            ident: env1

Using that config, we should be able to achieve the following log:

May 05 02:16:30 vagrant env1:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env1.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env1.dev.local/login","level":"critical"} []
May 05 02:18:32 vagrant env2:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env2.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env2.dev.local/login","level":"critical"} []

I will send a PR containing that change, soon. Please let me know if there is anything else I should do, as that`s my first PR/issue here.

@Seldaek Seldaek added this to the 3.4 milestone Dec 29, 2018
lyrixx added a commit that referenced this issue May 16, 2019
…fects #266 (dhirtzbruch)

This PR was merged into the 3.x-dev branch.

Discussion
----------

Allow setting "ident" parameter for SyslogUdpHandler, affects #266

As outlined in ticket #266:

The SyslogUdpHandler constructor has a sixth parameter "ident", defaulting to "php".
However, the current Monolog Bundle implementation allows setting only the first five. Which defaults to the "ident" being set to "php".
In our case, we are using papertrail as a log backend, and use the same webserver for multiple small projects. In papertrail, that results in the following output:

```
May 05 02:16:30 vagrant php:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env1.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env1.dev.local/login","level":"critical"} []
May 05 02:18:32 vagrant php:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env2.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env2.dev.local/login","level":"critical"} []
```

The "php" after "vagrant" is the ident configuration. As you can see, we are not able to determine the source environment, other than guessing from filepath or uri.
However, for filtering using the API, we`d like to be able to change the ident per configuration.

```
monolog:
    handlers:
        syslog:
            type: syslogudp
            host: example.com
            port: 514
            level: error
            ident: env1
```

Using that config, we should be able to achieve the following log:

```
May 05 02:16:30 vagrant env1:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env1.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env1.dev.local/login","level":"critical"} []
May 05 02:18:32 vagrant env2:  app.ERROR: fooo {"exception":"[object] (Exception(code: 0): fooo at /var/customers/webs/fastbolt/https/env2.fastbolt.com/src/Pricecalc/UserBundle/Controller/SecurityController.php:36)","username":"anon.","uri":"http://env2.dev.local/login","level":"critical"} []
```

Please let me know if there is anything else I should do, as that`s my first PR/issue here.

Commits
-------

9f6f0b6 Allow setting "ident" parameter for SyslogUdpHandler, affects #266
@lyrixx lyrixx closed this as completed May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants