[英]How can I get errors and exceptions ,and write them to log files?
在我的PHP項目中,我想在產品Server中獲得所有錯誤和異常。但是,如何獲取它們並將其寫入日志文件呢?
您可以在catch塊中執行此操作:
try {
foo();
} catch (Exception $e) {
error_log("Caught $e");
}
或在異常處理程序中:
set_exception_handler(function($exception) {
error_log($exception);
error_page("Something went wrong!");
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.