Check this post https://laracasts.com/discuss/channels/laravel/send-logs-to-a-custom-path-with-variables
Seems like its similar to what you're trying to achieve.
Is there any way to create log channels dynamically, or have one log channel that logs to a variable file?
Right now I have multiple "services" in my app, which need their own log file. This means that currently they're all defined like this in config/logging.php:
...
'service_1' => [
'driver' => 'single',
'path' => storage_path('logs/service_1.log'),
'level' => 'debug',
],
'service_2' => [
'driver' => 'single',
'path' => storage_path('logs/service_2.log'),
'level' => 'debug',
],
'service_3' => [
'driver' => 'single',
'path' => storage_path('logs/service_3.log'),
'level' => 'debug',
],
...
Is there any way to have a single channel with a variable log file, like this:
'service' => [
'driver' => 'single',
'path' => storage_path('logs/{service_name}.log'),
'level' => 'debug',
]
Or alternatively, can log channels be created dynamically without relying on what is configured in the logging.php config file? For example, create a macro for the Log facade, like Log::serviceLog() which would check if the provided channel exists, and create it if it does not.
Check this post https://laracasts.com/discuss/channels/laravel/send-logs-to-a-custom-path-with-variables
Seems like its similar to what you're trying to achieve.
Please or to participate in this conversation.