laravelɨ³ýËùÓÐÈÕÖ¾
laravelÊÇÒ»¸öÓÅÒìµÄphp¿ò¼Ü£¬ËüÌṩÁËÒ»¸öÎÞаµÄÈÕ־ϵͳ£¬¿ÉÒԼͼӦÓóÌÐòÖб¬·¢µÄÖÖÖÖÊÂÎñ¡£¿ÉÊÇ£¬³¤Ê±¼äµÄÈÕÖ¾¼Í¼¿ÉÄܻᵼÖÂÈÕÖ¾Îļþ¹ý´ó£¬Õ¼ÓôÅÅ̿ռ䣬ӰÏìЧÀÍÆ÷ÐÔÄÜ¡£ÔÚÕâÖÖÇéÐÎÏ£¬ÎÒÃÇÐèҪɨ³ýËùÓÐÈÕÖ¾ÎļþÀ´ÊÍ·Å´ÅÅ̿ռ䡣±¾ÎĽ«ÏÈÈÝÔõÑùɨ³ýlaravelÖеÄËùÓÐÈÕÖ¾Îļþ¡£
È·¶¨ÈÕÖ¾Îļþ·¾¶
ÔÚLaravelÖУ¬ËùÓеÄÈÕÖ¾Îļþ¶¼ÉúÑÄÔÚstorage/logsĿ¼Ï¡£
ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÕÒµ½ÈÕÖ¾Îļþ·¾¶£º
php artisan config:cache php artisan config:clear php artisan config:cache php artisan config:clear
µÇ¼ºó¸´ÖÆ
ÕâÑù×öµÄÄ¿µÄÊÇÈ·±£LaravelµÄÉèÖñ»×¼È·¼ÓÔØ¡£
È»ºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÕÒµ½ÈÕÖ¾Îļþ·¾¶£º
php artisan tinker
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÔÚTinkerÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´È·¶¨ÈÕÖ¾Îļþ·¾¶£º
use IlluminateSupportFacadesLog; Log::getLogger()->getHandlers()[0]->getUrl();
µÇ¼ºó¸´ÖÆ
ÕâÑù¾Í¿ÉÒÔÔÚTinkerÖлñÈ¡ÈÕÖ¾Îļþ·¾¶¡£¸´ÖƲ¢ÉúÑÄ·¾¶ÒÔ±¸ºóÓá£
ɨ³ýÈÕÖ¾Îļþ
ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´É¨³ýËùÓÐÈÕÖ¾Îļþ£º
php artisan tinker
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÔÚTinkerÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´É¨³ýËùÓÐÈÕÖ¾Îļþ£º
use IlluminateSupportFacadesFile; File::cleanDirectory('/path/to/logs');
µÇ¼ºó¸´ÖÆ
×¢ÖØÌæ»»/path/to/logsΪÄãÉúÑĵÄÈÕÖ¾Îļþ·¾¶¡£
ÕâÑù¾Í¿ÉÒÔɨ³ýLaravelÖÐËùÓеÄÈÕÖ¾Îļþ¡£ÈôÊÇÄúÖ»Ïëɨ³ýÌض¨ÈÕÆÚµÄÈÕÖ¾£¬¿ÉÒÔʹÓÃÒÔÏÂÓï·¨£¨ÀýÈ磬ɾ³ý2021Äê1ÔµÄÈÕÖ¾£©£º
use IlluminateSupportFacadesFile; File::cleanDirectory('/path/to/logs', 31, '2021-01-');
µÇ¼ºó¸´ÖÆ
×¢ÖØÌæ»»/path/to/logsΪÄãµÄÈÕÖ¾Îļþ·¾¶£¬31ÊÇÔ²Õûµ½ÖÜÄ©µÄÌìÊý£¬2021-01-ÊÇÄãÏëɾ³ýµÄÈÕÖ¾ÈÕÆÚ¡£
×Ô¶¯°´ÆÚɨ³ýÈÕÖ¾
ÊÖ¶¯É¨³ýËùÓÐÈÕÖ¾Îļþ¿ÉÄÜ»áºÜƶÀ§£¬ÓÉÓÚÄúÐèÒª¾³£Ö´Ðд˲Ù×÷¡£ÎªÁË×èÖ¹ÕâÖÖÇéÐΣ¬ÎÒÃÇ¿ÉÒÔÉèÖÃÍýÏëʹÃüÀ´×Ô¶¯É¨³ýÈÕÖ¾Îļþ¡£
±à¼Ð§ÀÍÆ÷ÉϵÄcrontabÎļþ£¬Ìí¼ÓÒÔÏÂÐУº
0 0 * * * php /path/to/artisan log:clear > /dev/null 2>&1
µÇ¼ºó¸´ÖÆ
Õ⽫ÔÚÌìÌìÎçÒ¹×Ô¶¯É¨³ýËùÓÐÈÕÖ¾¡£Ìæ»»/path/to/artisanΪÄãµÄartisanÎļþ·¾¶¡£
×ܽá
ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑùɨ³ýLaravelÖеÄËùÓÐÈÕÖ¾Îļþ¡£Äú¿ÉÒÔÊÖ¶¯É¨³ý»òÉèÖÃÍýÏëʹÃüÀ´°´ÆÚɨ³ýÈÕÖ¾¡£Õ⽫ïÔÌ´ÅÅÌ¿Õ¼äµÄʹÓã¬Ìá¸ßЧÀÍÆ÷ÐÔÄÜ¡£
ÒÔÉϾÍÊÇlaravelɨ³ýËùÓÐÈÕÖ¾µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡