Featured image of post Day 28. Log

Day 28. Log

資源

Laravel7 30天: 目錄
專案連結: github - laravel7 之 30 天分享

前言

專案連結: github - laravel7 之 30 天分享

上一篇: Day 27. Session

結束 session
今天要來聊聊 Log

主要

上文件

預設的 Log 是一個檔案
你可以在你的程式裏面埋入你要寫入的 Log 而這些 Log 會被存放在 storage/logs 裏面

你可以在 .env 設定你的 Log 類別
官方有提供很多種,
我都是使用 daily 每天會產生一個以日期為主的檔案

級別

1
2
3
4
5
6
7
8
Log::emergency($message);
Log::alert($message);
Log::critical($message);
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);

如何使用?

env 設定

使用

1
2
3
4
5
6
7
8
9
use Illuminate\Support\Facades\Log;

class TaskController extends Controller
{
    public function index()
    {
        Log::info('log test');
        // ...
    }

檢查

就是這樣簡單

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy