Result caching in Log Viewer
Log Viewer creates and caches indices for your log files so that further navigation is much, much faster.
When new logs are added to a log file, Log Viewer only scans the difference. This is possible because logs are appended at the end of the file and previously added contents will never change.
Configuring cache driver for Log Viewer
Before you're able to configure this, make sure to first publish the configuration file.
By default, Log Viewer uses your application's default cache driver.
To use a different cache driver for Log Viewer, you can set it with an .env
variable LOG_VIEWER_CACHE_DRIVER=redis
or with a config option in config/log-viewer.php
:
/* |-------------------------------------------------------------------------- | Cache driver |-------------------------------------------------------------------------- | Cache driver to use for storing the log indices. Indices are used to speed up | log navigation. Defaults to your application's default cache driver. | */ 'cache_driver' => env('LOG_VIEWER_CACHE_DRIVER', null),
Cache prefix
By default, Log Viewer will prefix all the cache keys it uses with lv:
. This ensures it does not clash with any of your application cache keys.
If, by any chance, you would like to configure this prefix, you can do so by changing cache_key_prefix
value in config/log-viewer.php
:
/* |-------------------------------------------------------------------------- | Cache key prefix |-------------------------------------------------------------------------- | Log Viewer prefixes all the cache keys created with this value. If for | some reason you would like to change this prefix, you can do so here. | The format of Log Viewer cache keys is: | {prefix}:{version}:{rest-of-the-key} | */ 'cache_key_prefix' => 'lv',
Disabling cache behaviour
At the moment it's not possible to disable caching behaviour.
But, if you'd like to prevent Log Viewer from saving lots of data to the cache, you might use Laravel's in-memory array
cache driver by setting .env
variable LOG_VIEWER_CACHE_DRIVER=array
. This way nothing will be persisted, but you will definitely notice slower loading times and higher memory usage when navigating the same file.
Cache compression
Since Log Viewer v3, cache compression is enabled by default, as long as you have zlib
extension enabled in your PHP environment.
Log Viewer will then automatically compress indices before storing them, resulting in 3-4x lower storage needs.
Clearing indices/cache
If things ever go weird, and you feel like Log Viewer is not showing what it's supposed to, you might want to clear indices and let them rebuild.
Clearing indices/cache via the UI
In order to clear the index for a single file, just open its menu and click on the "Clear index" button:
You can also clear all indices by clicking on the "Clear all indices" button in the top right corner:
Clearing indices via API requests
You can also clear indices via API calls, either clearing indices for individual files or whole folders.