0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

laravelで個別にログファイルを出力する

Posted at

まずは、ログ出力の設定から。
ログの出力設定はconfig/logging.phpで設定する

config/logging.php
'hoge' => [
    'driver' => 'daily',
    'path' => storage_path('logs/hoge/hoge_log.log'),
    'level' => 'info',
    'days' => 3, //保存期間
    'permission' => 0664,
],

あとは、出力したいControllerとかに
以下のログ出力用のコマンドを渡してあげればよい

HogeController.php
Log::channel('hoge')->info('なんかのログ', ここは配列);

テストしたいだけだったら以下を入れてみる。

HogeController.php
Log::channel('hoge')->info('test');
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?