laravelÈÕ־Ŀ¼ÐÞ¸Ä
laravelÊÇÒ»¸öÊ¢ÐеÄphp¿ò¼Ü£¬Ëü¼«´óµØ¼ò»¯ÁËweb¿ª·¢µÄÁ÷³Ì¡£ÔÚÒ»¸ölaravelÓ¦ÓÃÖУ¬logging£¨ÈÕÖ¾¼Í¼£©ÊÎÑÝןÜÊÇÖ÷ÒªµÄ½ÇÉ«¡£laravelʹÓÃÁËÒ»ÖÖÎÞаµÄlogϵͳ£¬¸ø¿ª·¢ÕßÌṩÁ˶àÖÖlogÇý¶¯£¬ÀýÈçÎļþ´æ´¢log¡¢Êý¾Ý¿â´æ´¢logµÈµÈ¡£ÔÚlaravelÖУ¬logging¿ÉÒÔºÜÊÇÈÝÒ׺ÍÓÅÑŵØʵÏÖ£¬¿ÉÊÇÓÐʱ¼äÐèÒª¶ÔËüµÄһЩÉèÖþÙÐÐÐ޸ĺͶ¨ÖÆ£¬ºÃ±È¸üËûÈÕ־Ŀ¼¡£
ĬÈÏÇéÐÎÏ£¬LaravelµÄÈÕÖ¾Îļþ»áÉúÑÄÔÚstorage/logsĿ¼Ï¡£ÔÚÏÖʵ¿ª·¢ÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒª½«ÈÕÖ¾ÉúÑÄÔÚÆäËûĿ¼ÖУ¬ÀýÈçϵͳĬÈϵÄ/var/logĿ¼¡£
ÄÇôÔÚLaravelÖÐÔõÑù¸üËûÈÕ־Ŀ¼ÄØ£¿
Ê×ÏÈ£¬ÎÒÃÇÐèÒª·¿ªÉèÖÃÎļþconfig/logging.php¡£ÔÚ¸ÃÎļþÖУ¬Äã¿ÉÒÔ¿´µ½LaravelĬÈÏÉèÖÃÁËÈý¸ölog channel£¨ÈÕ־ƵµÀ£©£ºstack¡¢single¡¢daily¡£ÆäÖÐstackÊÇÒ»¸öÓɶà¸öÈÕÖ¾Çý¶¯×éºÏ¶ø³ÉµÄchannel£¬singleʹÓõ¥ÎļþģʽÉúÑÄÈÕÖ¾£¬dailyÔò»áÒÔÈÕÆÚ×÷ΪÎļþÃûÀ´ÉúÑÄÈÕÖ¾£¬ÌìÌìÌìÉúÒ»¸öеÄlogÎļþ¡£
ÔÚÉèÖÃÎļþÖÐÕÒµ½channelsÊý×飺
'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', 'days' => 7, ], ],
µÇ¼ºó¸´ÖÆ
ÈçÉÏ´úÂëƬ¶ÏËùʾ£¬ÔÚsingleºÍdailyÁ½¸öchannelÖж¼ÓÐÒ»¸öpathÊôÐÔ£¬ËüÌåÏÖÈÕÖ¾ÎļþµÄÉúÑÄ·¾¶¡£ÐÞ¸ÄÕâ¸öÊôÐÔµÄÖµ¼´¿É¸ü¸ÄloggingµÄĿ¼¡£
ΪÁ˽«loggingÎļþÉúÑĵ½ÆäËûĿ¼£¬ÄãÐèÒªÔÚpathÖÐÌṩÐÂĿ¼µÄÍêÕû·¾¶¡£ÀýÈ磬ÈôÊÇÄãÏ뽫loggingÎļþÉúÑĵ½/var/logĿ¼Ï£¬Ôò½«pathÊôÐÔÉèÖÃΪ/var/log/laravel.log¼´¿É£º
'single' => [ 'driver' => 'single', 'path' => '/var/log/laravel.log', 'level' => 'debug', ],
µÇ¼ºó¸´ÖÆ
ÈôÊÇÄã³ýÁËÏëÒªÐÞËûÈÕÖ¾ÎļþÉúÑĵÄĿ¼֮Í⣬»¹ÏëÒª×Ô½ç˵ÈÕÖ¾ÎļþÃûºÍ·¾¶£¬Ôò¿ÉÒÔʹÓÃdaily channelÀ´ÊµÏÖ¡£daily channel½«»áÌìÌìÌìÉúÒ»¸öÈÕÖ¾Îļþ£¬Äã¿ÉÒÔͨ¹ýpathÉèÖÃÉúÑÄÎļþµÄĿ¼£¬Í¨¹ýfilenameÉèÖÃÎļþÃûǰ׺¡£
'daily' => [ 'driver' => 'daily', 'path' => '/var/log', 'filename' => 'laravel.log', 'level' => 'debug', 'days' => 7, ],
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄ´úÂëƬ¶ÏÖУ¬pathÊôÐÔÖ¸¶¨ÁËÉúÑÄÈÕÖ¾ÎļþµÄĿ¼£¬filenameÊôÐÔÖ¸¶¨ÁËÈÕÖ¾ÎļþµÄǰ׺Ãû£¬ÀýÈçÉèÖÃfilenameΪlaravel½«»áÌìÉúÀàËÆlaravel-2019-08-08.logµÄÎļþÃû¡£
ËäÈ»£¬ÈôÊÇÄãÓÐÔ½·¢ÖØ´óµÄloggingÐèÇó£¬ÈçʹÓÃ×Ô½ç˵µÄlogÇý¶¯¡¢½«logging¼Í¼µ½Êý¾Ý¿âµÈ£¬Äã¿ÉÒÔ¼ÌÐøÐÞ¸Äconfig/logging.phpÉèÖÃÎļþ¡£
×ÛÉÏ£¬LaravelµÄÈÕ־ϵͳºÜÊÇÎÞаǿʢ£¬Í¨¹ýÉÔ¼Ó¶¨ÖÆ£¬ÎÒÃÇÄܹ»ÍêÉƵØÖ§³ÖÖÖÖÖlogÐèÇó¡£
ÒÔÉϾÍÊÇlaravelÈÕ־Ŀ¼Ð޸ĵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡