问题描述
如何在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:如何记录信息以分隔文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!