简体   繁体   中英

how to setup multiple log files on Laravel?

I'm looking for solution of multiple log files on Laravel 4.2.

Right now, I'm using Laravel default setup which is log to laravel.log by Log::error($exception); . I need a way to be able write to laravel.log file and add ability to write also to mycustom.log some of special errors which is more critical to me and i would like to classify in another log file.

Thanks :)

A simple solution would be to register a log listener and do the saving yourself into mycustom.log if it matches your criteria. You can send additional data in the log $context variable.

Log::listen(function($level, $message, $context)
{
    // Save to mycustom.log
});

Laravel uses the Monolog logging library which contains plenty of other features though that you might want to look into. You can get an instance of Monolog by doing Log::getMonolog() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM