@extends('layouts.app') @section('content')
| ID | Level | Message | Source | Time |
|---|---|---|---|---|
| {{ $log->id }} | {{ $log->level }} | {{ Str::limit($log->message, 100) }} |
@if(isset($log->source_info))
{{ $log->source_info }}
@else
No source information
@endif
|
{{ $log->created_at->format('Y-m-d H:i:s') }} |
use Illuminate\Support\Facades\Log;
Log::debug('This is a debug message');
Log::info('This is an info message');
Log::notice('This is a notice message');
Log::warning('This is a warning message');
Log::error('This is an error message');
Log::error('An error occurred', [
'user_id' => $user->id,
'action' => 'update_profile',
'data' => $request->all()
]);
try {
// Some code that might throw an exception
} catch (\Exception $e) {
Log::error('An error occurred: ' . $e->getMessage(), [
'exception' => $e,
'user_id' => $user->id ?? null
]);
}
use App\Helpers\LogHelper;
// Get all logs with source information
$logs = LogHelper::getLogsWithSource();
// Get error logs with source information
$errorLogs = LogHelper::getLogsWithSource('error');
// Get a summary of error sources
$errorSources = LogHelper::getErrorSourcesSummary();