1. Go to this page and download the library: Download mikailfaruqali/log-viewer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mikailfaruqali / log-viewer example snippets
return [
/*
|--------------------------------------------------------------------------
| Log Viewer Route Path
|--------------------------------------------------------------------------
| This is the URI path where the log viewer will be accessible.
| Default: 'logs' (accessible at /logs)
|
*/
'route-path' => 'logs',
/*
|--------------------------------------------------------------------------
| Log Viewer Route Middleware
|--------------------------------------------------------------------------
| These middleware will be assigned to every route in the package.
| You can add your own middleware here to restrict access.
| Default: ['web', 'auth'] -
'route-path' => 'admin/logs', // Accessible at /admin/logs
// app/Http/Middleware/LogViewerAccess.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class LogViewerAccess
{
public function handle(Request $request, Closure $next)
{
if (!auth()->user()->hasRole('admin')) {
abort(403, 'Access denied to log viewer');
}
return $next($request);
}
}
// In a custom middleware
public function handle($request, Closure $next)
{
$allowedIps = ['192.168.1.100', '10.0.0.50'];
if (!in_array($request->ip(), $allowedIps)) {
abort(403);
}
return $next($request);
}
// In your middleware
Log::info('Log viewer accessed', [
'user' => auth()->user()->email,
'ip' => $request->ip(),
'user_agent' => $request->userAgent(),
]);
// In your .env file
LOG_LEVEL=debug
// This will log parsing errors and other debug information
// In a scheduled command
$this->command('log:clear --days=30'); // Keep 30 days of logs