laravel.logをclearする方法

はじめに

laravelのdebugでLog::Debug()を頻繁に使っていると、laravel.logはすぐに容量が増えてしまいます。


コード量が増えるとlogが見辛くなるので、こまめにclearしておきたいですよね。

clearの方法が分からずに放置していたら、今日ついにファイルサイズをオーバーしてしまいました。

これをこんな感じにしていきます。

解決策

解決策は簡単です。
プロジェクトパスで以下のコマンドを打つだけ。

cat /dev/null > storage/logs/laravel.log

軽く解説するとLinuxなどのOSにはdev/nullというブラックホール的なファイルがあります。
これ自身は空データでさまざまな使い道があります。

cat /dev/nul > "path"

でpathのファイルを空にできます。
今回はこれを使った訳です。

初学者時代にお世話になったLaravelの青本を添付

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
  • Attributes
  • Custom attributes
  • Custom fields
Click outside to hide the compare bar
Compare
Compare ×
Let's Compare! Continue shopping