15
13

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 5 years have passed since last update.

Laravel 4でログの出力項目を追加するワンライナー

15
Last updated at Posted at 2014-03-23

Laravel 4でログの出力項目を追加するワンライナー。

app/start/global.phpあたりに次のように書くと、ログの出力項目にリクエストURI、リクエストメソッド、クライアントIPアドレスを追加できる。

Log::getMonolog()->pushProcessor(new Monolog\Processor\WebProcessor);

また、次のように書くとプロセスIDを追加できる。

Log::getMonolog()->pushProcessor(new Monolog\Processor\ProcessIdProcessor); 

両方書くこともできる。(ワンライナーではなくなるけど(汗))

Log::getMonolog()->pushProcessor(new Monolog\Processor\WebProcessor);
Log::getMonolog()->pushProcessor(new Monolog\Processor\ProcessIdProcessor); 

この他にもpushProcessor()するオブジェクトに応じて出力項目を追加できる。
詳しくはMonologライブラリを参照。

15
13
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
15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?