laravelÔõôÉèÖñ¨´í¼¶±ð
ÔÚlaravel¿ª·¢ÖУ¬¹ýʧ´¦Öóͷ£Ò»Ö±ÊÇÒ»¸öÖ÷ÒªµÄ»°Ìâ¡£ÎÞÂÛÊÇÔÚ¿ª·¢Àú³ÌÖÐÕÕ¾ÉÔÚÔËÐÐʱ£¬³ÌÐòÖÐÄÑÒÔ×èÖ¹»á·ºÆðÖÖÖÖ¹ýʧ¡£ÕâЩ¹ýʧÐÅÏ¢²»µ«»áÓ°Ïì³ÌÐòµÄÔËÐУ¬Ò²»á¸ø¿ª·¢Õß´øÀ´Î´±ã¡£ÎªÁ˸üºÃµØ´¦Öóͷ£ÕâЩ¹ýʧ£¬laravelÌṩÁËÒ»ÖÖÀû±ãµÄ¹ýʧ±¨¸æ»úÖÆ¡£³ýÁË»ù±¾µÄ¹ýʧ±¨¸æÍ⣬laravel»¹ÌṩÁ˸ü¸ß¼¶µÄ±¨¸æ»úÖÆ£¬Ê¹¿ª·¢ÕßÄܹ»¸ü¿ìËÙµØʶ±ðÏ¢Õù¾öÎÊÌâ¡£
ÔÚLaravelÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÉèÖÃÎļþÀ´ÉèÖùýʧÐÅÏ¢µÄ¼¶±ð£¬ÒÔ¼°ÔõÑù¼Í¼ºÍ´¦Öóͷ£¹ýʧ¡£ÔÚĬÈÏÇéÐÎÏ£¬Laravel»á½«ËùÓÐ䲶»ñµÄÒì³£ºÍ¹ýʧ¶¼¼Í¼ÔÚÒ»¸öÈÕÖ¾ÎļþÖС£ÕâЩ¼Í¼½«°üÀ¨¹ýʧµÄ¼¶±ð¡¢¹ýʧʱ¼ä¡¢¹ýʧÐÅÏ¢¡¢ÎļþÃûÒÔ¼°Ðкš£ÎÒÃÇ¿ÉÒÔƾ֤ÐèÒªÀ´ÉèÖùýʧ±¨¸æµÄ¼¶±ðºÍ·½·¨£¬ÏêϸÈçÏ£º
ÉèÖùýʧ±¨¸æ¼¶±ð
LaravelÌṩÁ˲î±ðµÄ¹ýʧ¼¶±ðÀ´×ÊÖúÎÒÃǸüºÃµØ´¦Öóͷ£¹ýʧ¡£ÕâЩ¹ýʧ¼¶±ð°üÀ¨£º
debug: ÓÃÓÚ¿ª·¢ÇéÐΣ¬ÔÚ¿ØÖÆ̨Êä³öÏêϸµÄ¹ýʧÐÅÏ¢¡£
info: ÓÃÓÚÉú²úÇéÐΣ¬ÔÚ¿ØÖÆ̨Êä³ö¼òÒªµÄ¹ýʧÐÅÏ¢¡£
notice: ÓÃÓÚÉú²úÇéÐΣ¬¼Í¼¹ýʧÐÅÏ¢µ«²»Ó°Ïì³ÌÐòµÄÔËÐС£
warning: ÓÃÓÚÉú²úÇéÐΣ¬ÌåÏÖÒ»¸öÖÒÑÔÐÅÏ¢£¬ÐèÒª±»×¢ÖØ¡£
error: ÓÃÓÚÉú²úÇéÐΣ¬ÌåÏÖÒ»¸ö¹ýʧ£¬³ÌÐò¿ÉÄÜÎÞ·¨¼ÌÐøÖ´ÐС£
critical: ÓÃÓÚÉú²úÇéÐΣ¬ÌåÏÖÒ»¸öÑÏÖصĹýʧ£¬³ÌÐò±ØÐèÖÐÖ¹¡£
ÎÒÃÇ¿ÉÒÔÔÚconfig/app.phpÎļþÖоÙÐÐÉèÖã¬ÕÒµ½ÈçÏ´úÂ룺
'log_level' => env('APP_LOG_LEVEL', 'debug'),
µÇ¼ºó¸´ÖÆ
½«ÆäÖеÄlog_level×Ö¶ÎÉèÖÃΪÐèÒªµÄ¼¶±ð¼´¿É¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔ½«ËüÉèÖÃΪerror¼¶±ð£º
'log_level' => 'error',
µÇ¼ºó¸´ÖÆ
¹ýʧÈÕÖ¾¼Í¼·½·¨
LaravelÖ§³Ö¶àÖÖ²î±ðµÄÈÕÖ¾¼Í¼·½·¨£¬ÎÒÃÇ¿ÉÒÔƾ֤ÐèÇóÀ´Ñ¡ÔñʹÓÃÄÄÖÖ·½·¨¡£ÔÚconfig/logging.phpÎļþÖУ¬ÎÒÃÇ¿ÉÒÔÕÒµ½ÈçÏ´úÂ룺
'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', ], ],
µÇ¼ºó¸´ÖÆ
Õâ¸öÎļþÖаüÀ¨ÁËLaravelÖ§³ÖµÄËùÓÐÈÕÖ¾¼Í¼·½·¨¡£ÔÚĬÈÏÇéÐÎÏ£¬Laravel»áʹÓà single Õâ¸öͨµÀ£¬½«ÈÕÖ¾¼Í¼µ½ storage/logs/laravel.log ÎļþÖС£³ýÁË single Í⣬Laravel»¹Ö§³Ö daily¡¢syslog¡¢slack¡¢emailµÈ¶à¸öͨµÀ¡£ÎÒÃÇ¿ÉÒÔƾ֤ÐèÒªÀ´Ñ¡ÔñʹÓÃÄĸöͨµÀ£¬ÒÔ¼°ÔõÑù¼Í¼ÈÕÖ¾¡£
¹ýʧ±¨¸æÌáÐÑ·½·¨
³ýÁ˽«¹ýʧÐÅÏ¢¼Í¼ÔÚÈÕÖ¾ÎļþÖÐÍ⣬Laravel»¹¿ÉÒÔÔÚ¿ª·¢ÇéÐÎÖÐÖ±½ÓÔÚ¿ØÖÆ̨ÖÐÊäÍÉ»¯ÎóÐÅÏ¢£¬ÓÃÀ´×ÊÖúÎÒÃǸü¿ìµØ¶¨Î»ÎÊÌâ¡£ÎÒÃÇ¿ÉÒÔÔÚconfig/app.phpÎļþÖÐÉèÖÃÈçÏ´úÂ룺
'debug' => env('APP_DEBUG', false),
µÇ¼ºó¸´ÖÆ
½«ÆäÖеÄdebug×Ö¶ÎÉèÖÃΪtrue¼´¿É¡£µ±³ÌÐòÓöµ½¹ýʧʱ£¬Laravel½«»áÔÚ¿ØÖÆ̨ÖÐÊä³öÏêϸµÄ¹ýʧÐÅÏ¢¡£ÔÚÉú²úÇéÐÎÖУ¬Õâ¸öÑ¡ÏîÓ¦¸ÃÉèΪfalse£¬ÒÔ×èÖ¹½«¹ýʧÐÅÏ¢Ö±½Ó̻¶¸øÓû§¡£
×ܽ᣺
ÔÚLaravel¿ª·¢ÖУ¬×¼È·´¦Öóͷ£¹ýʧÐÅÏ¢ÖÁ¹ØÖ÷Òª¡£ÓÅÒìµÄ¹ýʧ´¦Öóͷ£»úÖÆ¿ÉÒÔ×ÊÖúÎÒÃǸü¿ìËÙ¡¢¸ü¸ßЧµØ¶¨Î»Ï¢Õù¾öÎÊÌâ¡£LaravelÌṩÁ˶àÖÖÑ¡ÏîÀ´´¦Öóͷ£¹ýʧÐÅÏ¢£¬ÎÒÃÇ¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´Ñ¡ÔñºÍÉèÖã¬ÒÔʵÏÖ×î¼ÑµÄ¿ª·¢ÌåÑéºÍÓû§ÌåÑé¡£
ÒÔÉϾÍÊÇlaravelÔõôÉèÖñ¨´í¼¶±ðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡