DEV Community

Manish Chaudhary
Manish Chaudhary

Posted on • Edited on

3 3

Add Laravel Log to separate file

Recently I got a a requirement to add separate log file for registration with details like ip and user agent. I did some research and found an awesome trick which is available built in to laravel.

The code looks like this.

 Log::useDailyFiles(storage_path().'/logs/file_name.log');
//Log::useFiles(storage_path().'/logs/file_name.log'); alternative for single file
 Log::info([log  info]);
Enter fullscreen mode Exit fullscreen mode

Reference
Laravel : How to Log INFO to separate file

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up