[英]How can I get errors and exceptions ,and write them to log files?
在我的PHP项目中,我想在产品Server中获得所有错误和异常。但是,如何获取它们并将其写入日志文件呢?
You can do this in a catch block: 您可以在catch块中执行此操作:
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!");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.