文章内容

2022/3/3 10:10:40,作 者: 黄兵

Python 日志记录使用体验

最近写的服务,部署到服务器上,使用 Python 编写的代码,下面是日志记录的示例:

03-02 17:33 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 17:34 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 17:35 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', OSError(0, 'Error')).
03-02 17:43 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 17:45 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 17:49 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 17:49 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 17:50 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 19:11 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 19:12 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 19:14 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 19:18 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', OSError(0, 'Error')).
03-02 19:18 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 19:19 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 19:24 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 19:25 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 19:26 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 19:26 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', OSError(0, 'Error')).
03-02 19:34 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 19:35 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 19:54 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 19:56 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 20:09 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:09 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:09 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 20:10 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:10 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:15 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 20:15 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 20:16 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 20:16 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 20:17 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:18 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:18 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 20:18 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 22:25 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: HTTPSConnectionPool(host='api.bgpview.io', port=443): Read timed out. (read timeout=20).
03-02 22:30 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 22:30 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)).
03-02 22:30 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 22:32 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 22:33 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).
03-02 22:34 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: HTTPSConnectionPool(host='api.bgpview.io', port=443): Read timed out. (read timeout=20).
03-02 22:35 process_country_asn ERROR    调用API的过程出现错误,具体错误内容: ('Connection aborted.', OSError(0, 'Error')).

上面的错误消息很难知道具体是哪个 API 出现了问题,调用 API 的过程出现了错误,具体是那个 API 也没有提示,所以还是需要在日志中写明是哪个 API 出现了错误,否则为后面你的排查工作带来了很多麻烦。

以上就是关于使用 Python logging 使用的一点体会。

不断总结,不断学习。


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - Python 日志记录使用体验

分享到:

发表评论

评论列表