Laravel:如何记录信息到单独的文件 [英] Laravel : How to Log INFO to separate file
问题描述
如何在Laravel 5.1
中为logging INFO
指定单独的文件?
How to specify a separate file for logging INFO
in Laravel 5.1
?
任何即时帮助将非常可贵.谢谢
Any immediate help will be highly appreciable. Thanks
推荐答案
是否要专门将info
登录到一个日志文件,将另一种日志类型登录到另一个位置?在这种情况下,我的解决方案可能无济于事,但仍然可能有用.
Do you want to specifically log info
to one log file and another log type to another location? My solution might not help in that case, but could still be useful.
要将日志文件写入另一个位置,请使用方法useDailyFiles
或useFiles
,然后使用info信息以刚刚指定的路径登录到日志文件.像这样:
To write a log file to another location, use the method useDailyFiles
or useFiles
, and then info to log to the log file at the path you just specified. Like so:
Log::useDailyFiles(storage_path().'/logs/name-of-log.log');
Log::info([info to log]);
这两种方法的第一个参数是日志文件的路径(如果尚不存在则创建),而对于useDailyFiles
,第二个参数是Laravel在擦除旧日志之前将要记录的天数.默认值为无限制,因此在我的示例中,我没有输入任何值.
The first parameter for both methods is the path of the log file (which is created if it doesn't already exist) and for useDailyFiles
the second argument is the number of days Laravel will log for before erasing old logs. The default value is unlimited, so in my example I haven't entered a value.
这篇关于Laravel:如何记录信息到单独的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!