問題描述
如何在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:如何記錄信息以分隔文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!