2017-01-23 8 views
0

実稼働環境でカスタムチャネルを印刷しようとしています。これはdev環境でうまく動作します。私はいつでもエラーではなくログに記録します。symfony 2.7のカスタムロガーチャネルが本番環境で印刷されない

以下

生産のための私の設定です:

monolog: 
channels: ["always"] 
handlers: 
    main: 
     type:   fingers_crossed 
     action_level: error 
     handler:  nested 
     channels: ["!always"] 
    nested: 
     type: stream 
     path: "%kernel.logs_dir%/%kernel.environment%.log" 
     level: debug 
    console: 
     type: console 
    always: 
     type: stream 
     path: "%kernel.logs_dir%/%kernel.environment%.log" 
     level: debug 
     channels: ['always'] 

これは、開発のための私の設定です:ここ

monolog: 
channels: ["always"] 
handlers: 
    main: 
     type: stream 
     path: "%kernel.logs_dir%/%kernel.environment%.log" 
     level: debug 
     channels: ["!always"] 
    console: 
     type: console 
     bubble: false 
     verbosity_levels: 
      VERBOSITY_VERBOSE: INFO 
      VERBOSITY_VERY_VERBOSE: DEBUG 
     channels: ["!doctrine"] 
    console_very_verbose: 
     type: console 
     bubble: false 
     verbosity_levels: 
      VERBOSITY_VERBOSE: NOTICE 
      VERBOSITY_VERY_VERBOSE: NOTICE 
      VERBOSITY_DEBUG: DEBUG 
     channels: ["doctrine"] 
    always: 
     type: stream 
     path: "%kernel.logs_dir%/%kernel.environment%.log" 
     level: debug 
     channels: always 

は、ログからの例です:

[2017-01-23 14:17:39] always.INFO: STAR REMOTE CONTROL FROM DEFAULT CONTROLLER [] [] 

ここでは、私はそれをどう呼びますか:

/** 
    * @param Request $request 
    * @return Response 
    * @throws \Exception 
    * @Route("/star-remote-control") 
    * 
    */ 
    public function starRemoteControlAction(Request $request) 
    { 
    $this->container->get('monolog.logger.always')->info('STAR REMOTE CONTROL FROM DEFAULT CONTROLLER'); 
    ... 

なぜそれがprod.logに表示されないのかをトラブルシューティングできますか?

答えて

0

チェックアウトofficial documentation about the fingers_crossed handler

それは、要求時にすべてのログメッセージを保存するが、メッセージのいずれかがaction_levelに達した場合のみ、第二のハンドラに渡します。 PROD環境で

あなたの行動レベルはエラーですが、実際に情報メッセージをログに記録されています。アクションレベルまたはログを変更してください。エラーまたはクリティカルメッセージが表示され、エントリはプロダクトログファイルに表示されます。

+0

ありがとうございましたが、リンクが動作しません。 – ScottGutman

+0

@ScottGutmanはリンクを固定しました – lordrhodos

0

私の問題に対する答えは、本当にハンドラの順序に関するものでした。私がしなければならないことは、 "fingers_crossed"ハンドラの前に "Always"ハンドラを一番上に移動して、ログが欲しいと正確に書かれたことだけでした。ここで

config_prod.yml

monolog: 
channels: ["always"] 
handlers: 
    always: 
     type: stream 
     path: "%kernel.logs_dir%/%kernel.environment%.log" 
     level: debug 
     channels: ["always"] 
    main: 
     type:   fingers_crossed 
     action_level: error 
     handler:  nested 
     channels: ["!always"] 
    nested: 
     type: stream 
     path: "%kernel.logs_dir%/%kernel.environment%.log" 
     level: debug 
    console: 
     type: console 
+0

通常は、環境負荷の高い環境でデバッグ出力をしたくないので、これはあなたの問題を解決する最良の方法ではありません。多分あなたのためにはうまくいくかもしれませんが、あなたがプロジェクトでもっと進歩を遂げたらそれを再定義する必要があるでしょう;-) – lordrhodos

関連する問題