[ECCUBE4]ログフォーマットの変更(monolog,formatter)


環境

項目
ECCUBEバージョン 4.0.5

結論

<ECCUBEルート>/app/config/eccube/services.yaml内の定義eccube.log.formatter.lineargumentsの値を変更します。

app/config/eccube/services.yaml
    eccube.log.formatter.line:
        class: Monolog\Formatter\LineFormatter
        arguments:
            - "[%%datetime%%] %%channel%%.%%level_name%% [%%extra.session_id%%] [%%extra.uid%%] [%%extra.user_id%%] [%%extra.class%%:%%extra.function%%:%%extra.line%%] - %%message%% %%context%% [%%extra.http_method%%, %%extra.url%%, %%extra.ip%%, %%extra.referrer%%, %%extra.user_agent%%]\n"

備考

ログの設定(出力先、ファイル名、フォーマット、ローテーション定義等)は、実行モード(開発or本番)ごとに用意されていて、この中のformatterで上記の定義が指定されています。

<ECCUBEルート>/app/config/eccube/packages/dev/monolog.yml
<ECCUBEルート>/app/config/eccube/packages/prod/monolog.yml