まぁドキュメントを読めばわかることだけど,英語ドキュメントしかなさそうなのでメモ代わりに簡単に cakephp3 でログを出力する方法を書いておきます.
まず,config/app.php に記述追加.debug とか error ログの記述があるのでその並びに
'shops' => [
'className' => 'File',
'path' => LOGS,
'levels' => ,
'scopes' => ['orders', 'payments'],
'file' => 'shops.log',
],
'payments' => [
'className' => 'File',
'path' => LOGS,
'levels' => ,
'scopes' => ['payments'],
'file' => 'payments.log',
],
な感じにでも.
debug とか error ログに混ぜてもいいなら上記の記述は必要ないですけど.
で,出力したい Controller の先頭に
use Cake\Log\Log;
を記述してから log 出力したい箇所で
Log::warning('this gets written only to shops.log', ['scope' => ['orders']]);
Log::warning('this gets written to both shops.log and payments.log', ['scope' => ['payments']]);
Log::warning('this gets written to both shops.log and payments.log', ['scope' => ['unknown']]);
などの記述をすれば,scope に応じて shop.log と payments.log などに分けられてログ出力されます.
上記では warning() 関数を使っていますが,この他に emergency(), alert(), critical(), error(), notice(), debug(), info() などの関数があるのでお好きなものをどうぞ.
もっと詳しいことがやりたければ...やっぱりドキュメント(Cookbook)を見てくださいな.
はい.