admin管理员组文章数量:1421262
I am using Tenancy for Laravel (Stancl/Tenancy), Laravel 11, package. Everything working well. I want to know how to supply name of channel as a variable to log messages in the tenant's folder using log channel.
As an example below
Log::channel('activity')->info('['.tenant('id')." ] [ ".Auth::user()->name.' ] displayed consumption form');
The above line writes using activity log channel and stores well as I have defined the 'activity' channel.
Just like that, I want to use variable name instead of the channel name 'activity' like tenant('id').
As a test case I created 'demo' channel in logging.php file as the function tenant('id') points to tenant name 'demo' as mentioned below
Log::channel(tenant('id'))->info('['.tenant('id')." ] for [ ".Auth::user()->name.' ] displayed consumption form')
;
The above does not create/write to the file in 'demo' directory meant for the tenant (of course, I have given correct path in the logging.php file. However, if I write 'demo' instead of tenant('id'), it works. Also, in every function if I declare as written below
$logChannel = tenant('id');
and use the $logChannel also works, but I am forced to use this declaration everywhere which I wish to avoid.
How to mention or whether we can supply variable name in the Log::channel($variable)->info();
本文标签:
版权声明:本文标题:logging - Log messages to file present tenant's directory when using tenancy for laravel (Stancltenancy) - Stack Overflo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744758103a2623584.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论