在我的PHP项目中,我想在产品Server中获得所有错误和异常。但是,如何获取它们并将其写入日志文件呢?
You can do this in a catch block:
try {
foo();
} catch (Exception $e) {
error_log("Caught $e");
}
Or in the exception handler:
set_exception_handler(function($exception) {
error_log($exception);
error_page("Something went wrong!");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.