Lumen custom error log file and lumen Log File
Customize error log files and rebuild new methods
<? Phpnamespace App; use Monolog \ Logger; use Monolog \ Handler \ StreamHandler; use Monolog \ Formatter \ LineFormatter; class LogLib {// define static log instance. protected static $ _ log_instance;/*** Get log instance ** @ return obj * @ author Sphenginx **/public static function getLogInstance () {if (static :: $ _ log_instance === null) {static: $ _ log_instance = new Logger ('notice');} return static: $ _ log_instance ;}/ * ** Handle dynamic, static callto the object. ** @ param string $ method available methods: debug | info | notice | warning | error | critical | alert | for callable methods of emergency, see Monolog \ Logger class * @ param array $ args call parameter * @ return mixed * @ author Sphenginx */public static function _ callStatic ($ method, $ args) {$ instance = static: getLogInstance (); // organization parameter information $ message = $ args [0]; // record the context log $ context = isset ($ args [1])? $ Args [1]: []; // defines the log file $ path = isset ($ args [2])? $ Args [2]: '/notice/'; // set the log processing handle. The default value is to write files (mail, console, db, redis, and other methods, for details, see the Monolog \ handler directory) $ handler = new StreamHandler (storage_path ($ path ). date ('Y-m-d '). '. log', Logger: toMonologLevel ($ method), $ bubble = true, $ filePermission = 0777); // set the output format LineFormatter (Monolog \ Formatter \ LineFormatter ), ignore context and extra $ handler-> setFormatter (new LineFormatter (null, null, true, true); $ instance-> setHandlers ([$ handler]); $ instance-> $ method ($ message, $ context );}}