2017-06-30 33 views
0

我正在努力與monolog配置相當長的一段時間,並希望你能幫助我。monolog處理程序的組合似乎不起作用

我希望我的應用程序從向上

2),但在錯誤的所有可用的日誌(或者如果可能的話只對信息向上所有日誌)的情況下,通知登錄

1)evrything。

我就是這樣,雖然它可能工作:收集日誌從fingers_crossed和A ,重複數據刪除它們,並將它們發送到syslog

handlers: 
    filter_for_errors: 
     type: fingers_crossed 
     action_level: error 
     handler: unique 

    standard: 
     type: stream 
     level: notice 
     handler: unique 
     formatter: monolog.formatter.session_request 

    unique: 
     type: deduplication 
     handler: log2Syslog 

    log2Syslog: 
     type: syslog 
     facility: local5 
     ident: shop 
     formatter: monolog.formatter.session_request 
     level: info 

難道你一見我的錯誤或有較深的造詣關於哪些處理程序可以組合,哪些不是?

目前我只看到錯誤日誌行。

回答

0

您可以嘗試使用處理程序。

# app/config/config_prod.yml 
monolog: 
handlers: 
    main: 
     type:   fingers_crossed 
     action_level: critical 
     handler:  grouped 
    grouped: 
     type: group 
     members: [streamed, deduplicated] 
    streamed: 
     type: stream 
     path: '%kernel.logs_dir%/%kernel.environment%.log' 
     level: debug 
    deduplicated: 
     type: deduplication 
     handler: swift 
    swift: 
     type:  swift_mailer 
     from_email: '[email protected]' 
     to_email: '[email protected]' 
     subject: 'An Error Occurred! %%message%%' 
     level:  debug 
     formatter: monolog.formatter.html 
     content_type: text/html 

此處瞭解詳情:http://symfony.com/doc/current/logging/monolog_email.html

https://github.com/Seldaek/monolog/blob/master/doc/02-handlers-formatters-processors.md

GroupHandler:此處理程序組其他處理。收到的每個記錄 都會發送到所有配置的處理程序。

+0

Thx爲您的答案,St0iK。 據我瞭解你的解決方案,你正在從fingers_crossed處理程序收集你的日誌,並通過組處理程序傳播到一個文件日誌和(重複數據刪除)的電子郵件。 我需要的是結合流和fingers_crossed處理程序,從兩個源生成的行重複刪除並將它們發送到系統日誌(或文件日誌或以往)。我不明白,小組處理人員如何在那裏幫助? –