我需要为两种不同的情况登录到两个不同的文件。就像这样:
Log::channel('case1')->info('msg1'),
Log::channel('case2')->info('msg2'),
我怎么能在Lumen做这件事?
我读到了Laravel通过https://laravel.com/docs/5.6/logging#customizing-monolog-for-channels频道做这件事的方式,然后给这样一个频道打电话:Log::channel('custom-channel')->info('msg'),但是你是如何与Lumen一起工作的呢?我似乎找不到config/logging.php文件(我只在src外部的laravel/腔框架回购中看到它,但它不在laravel/腔中)
如果您知道如何实现这一点,请提供一些代码示例。谢谢:)
发布于 2020-03-14 13:47:35
在这种情况下对我起作用的是:
$log1 = app('Psr\Log\LoggerInterface')->channel('case1');
$log2 = app('Psr\Log\LoggerInterface')->channel('case2');
...
$log1->info('msg1');
...
$log2->info('msg2');
...当然,您必须创建一个config/logging.php,就像Laravel中的一样。在这里,您定义了'case1‘和'case2’通道。这将由框架自动获取。
https://stackoverflow.com/questions/50234576
复制相似问题