🎉 Enjoying this package? Consider sponsoring me on GitHub or buying me a beer.
Purging and Exporting Logs
Purging Old Logs
You may clear the old authentication log records using the authentication-log:purge Artisan command:
1php artisan authentication-log:purge
Records that are older than the number of days specified in the purge option in your config/authentication-log.php will be deleted.
1'purge' => 365,
You can also schedule the command at an interval:
1$schedule->command('authentication-log:purge')->monthly();
Exporting Logs
Export authentication logs to CSV or JSON format using the authentication-log:export command:
Basic Export
1# Export all logs to CSV2php artisan authentication-log:export --format=csv3 4# Export all logs to JSON5php artisan authentication-log:export --format=json
Filtered Export
1# Export logs from last 30 days 2php artisan authentication-log:export --format=csv --days=30 3 4# Export logs for specific user 5php artisan authentication-log:export --format=json --user=1 6 7# Specify output file 8php artisan authentication-log:export --format=csv --output=logs.csv 9 10# Combine filters11php artisan authentication-log:export --format=csv --days=7 --user=1 --output=user-logs.csv
Export Options
--format: Export format (csvorjson) - default:csv--days: Export logs from last N days--user: Filter by user ID--output: Output file path (default:authentication-logs-{format}-{timestamp}.{ext})
Export Contents
The export includes:
- Log ID
- User information (type, ID, email)
- IP address and user agent
- Device information (ID, name, trusted status)
- Login/logout timestamps
- Success status
- Suspicious activity flags
- Location data (if available)