0

Is it possible to format the log for syslog? The config.yml configuring syslog:

monolog:
    channels: ['auth']
    handlers:    
    auth:
        type: syslog
        level: debug
        facility: local0
        channels: [auth]

The resulting line printed in case of a warning:

Sep 20 15:43:31 api2 [10227]: auth.WARNING: invalid password {"method":"ApiBundle\\Api.....

The line as I'd like to see:

Sep 20 15:43:31 api2 auth.WARNING[10227]: invalid password {"method":"ApiBundle\\Api.....

I tried to use a formatter with no luck:

# config.yml
monolog:
    ...
    handlers:
    auth:
        ...
        formatter: monolog.formatter.auth_exception

# services.yml
monolog.formatter.auth_exception:
    class: Monolog\Formatter\LineFormatter
    arguments:
        - "[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
paddel10
  • 170
  • 1
  • 12

1 Answers1

0

In the end I used the following config:

# config.yml
monolog:
    channels: ['weather', 'auth']
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      syslog_handler
        syslog_handler:
            type: syslog
            level: debug
        console:
            type:  console
        app:
            type: syslog
            level: debug
            channels: ['weather']
        auth:
            type: syslog
            level: warning
            facility: auth
            channels: [auth]
paddel10
  • 170
  • 1
  • 12