Default Log Types
Log Viewer v3 now supports reading additional types of logs. It comes with a few pre-built log parsers already:
Log type | Log class |
---|---|
laravel | Opcodes\LogViewer\Logs\LaravelLog |
horizon | Opcodes\LogViewer\Logs\HorizonLog |
horizon_old | Opcodes\LogViewer\Logs\HorizonOldLog |
http_access | Opcodes\LogViewer\Logs\HttpAccessLog |
http_error_apache | Opcodes\LogViewer\Logs\HttpApacheErrorLog |
http_error_nginx | Opcodes\LogViewer\Logs\HttpNginxErrorLog |
php_fpm | Opcodes\LogViewer\Logs\PhpFpmLog |
postgres | Opcodes\LogViewer\Logs\PostgresLog |
redis | Opcodes\LogViewer\Logs\RedisLog |
supervisor | Opcodes\LogViewer\Logs\SupervisorLog |
All of these extend the base log class, Opcodes\LogViewer\Logs\Log
.
In order to start reading these types of logs, make sure to include the related paths in the config/log-viewer.php
configuration.
Extending a pre-built log type
In some cases your logs may vary, and you might need to adjust the Regular Expression used, or to capture additional data points. In that case, it's useful to create your own Log class that extends the pre-built class from Log Viewer, and register it within the Log Viewer.
For example, suppose you need to extend the laravel
type. You would first create your own LaravelLog
class that extends (optionally) the Log Viewer's class:
use Opcodes\LogViewer\Logs\LaravelLog;class CustomLaravelLog extends LaravelLog{ //}
Make any modifications you need (refer to the Custom Log Types page for information on the available configuration options), and then register your class in the AppServiceProvider
:
use Opcodes\LogViewer\Facades\LogViewer;/** * Bootstrap any application services. * * @return void */public function boot(){ LogViewer::extend('laravel', CustomLaravelLog::class);}
Your provided Log class will take precedence over the Log Viewer ones, but if it does not match a particular log file, it will then fall back to the Log Viewer's default implementation.
Log Viewer assumes that a single file contains only one format (i.e. Horizon logs should not be mixed with Laravel logs in the same file).