How to specify a separate file for logging INFO
in Laravel 5.1
?
Any immediate help will be highly appreciable. Thanks
You should be checking the root directory and not the app directory. Look in $ROOT/storage/laravel. log not app/storage/laravel. log , where root is the top directory of the project.
By default, Laravel is configured to create a single log file for your application, and this file is stored in app/storage/logs/laravel. log .
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.
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]);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With