{"id":1021295,"date":"2024-12-27T13:21:19","date_gmt":"2024-12-27T05:21:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1021295.html"},"modified":"2024-12-27T13:21:21","modified_gmt":"2024-12-27T05:21:21","slug":"python%e5%a6%82%e4%bd%95%e8%be%93%e5%87%ba%e6%97%a5%e5%bf%97%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1021295.html","title":{"rendered":"python\u5982\u4f55\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25163539\/02e04f4d-17f7-412d-9b8c-4e6ef148ab03.webp\" alt=\"python\u5982\u4f55\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6\u7684\u6838\u5fc3\u6b65\u9aa4\u5305\u62ec<strong>\u4f7f\u7528logging\u6a21\u5757\u3001\u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\u3001\u914d\u7f6e\u65e5\u5fd7\u683c\u5f0f\u3001\u9009\u62e9\u65e5\u5fd7\u8f93\u51fa\u4f4d\u7f6e\u3001\u521b\u5efa\u65e5\u5fd7\u8bb0\u5f55\u5668<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528logging\u6a21\u5757\u662f\u6700\u57fa\u672c\u7684\u65b9\u5f0f\u3002\u901a\u8fc7\u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\uff0c\u53ef\u4ee5\u8fc7\u6ee4\u6389\u4e0d\u9700\u8981\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u800c\u914d\u7f6e\u65e5\u5fd7\u683c\u5f0f\u5219\u80fd\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3\u65e5\u5fd7\u5185\u5bb9\u3002\u9009\u62e9\u65e5\u5fd7\u8f93\u51fa\u4f4d\u7f6e\u53ef\u4ee5\u662f\u63a7\u5236\u53f0\u3001\u6587\u4ef6\uff0c\u751a\u81f3\u662f\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5bfc\u5165Python\u7684\u5185\u7f6e\u6a21\u5757logging\u3002\u63a5\u7740\uff0c\u901a\u8fc7logging.basicConfig()\u51fd\u6570\u6765\u914d\u7f6e\u65e5\u5fd7\u7684\u8f93\u51fa\u76ee\u7684\u5730\u3001\u683c\u5f0f\u548c\u7ea7\u522b\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u8bbe\u7f6e\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\u6765\u5b58\u50a8\u65e5\u5fd7\u4fe1\u606f\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>logging.basicConfig(filename=&#39;app.log&#39;, level=logging.INFO, <\/p>\n<p>                    format=&#39;%(asctime)s - %(levelname)s - %(message)s&#39;)<\/p>\n<p>logging.info(&#39;This is an informational message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u65e5\u5fd7\u88ab\u5199\u5165\u5230\u540d\u4e3a&#39;app.log&#39;\u7684\u6587\u4ef6\u4e2d\uff0c\u65e5\u5fd7\u7ea7\u522b\u8bbe\u7f6e\u4e3aINFO\uff0c\u65e5\u5fd7\u683c\u5f0f\u5305\u62ec\u65f6\u95f4\u3001\u65e5\u5fd7\u7ea7\u522b\u548c\u6d88\u606f\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5728Python\u7a0b\u5e8f\u4e2d\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6\uff0c\u4ee5\u4fbf\u4e8e\u8c03\u8bd5\u548c\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8Python\u65e5\u5fd7\u8f93\u51fa\u7684\u76f8\u5173\u7ec6\u8282\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528 LOGGING \u6a21\u5757<\/p>\n<\/p>\n<p><p>Python\u4e2d\u7684logging\u6a21\u5757\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u8bb0\u5f55\u548c\u7ba1\u7406\u65e5\u5fd7\u4fe1\u606f\u3002\u5b83\u63d0\u4f9b\u4e86\u591a\u4e2a\u7ea7\u522b\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\uff0c\u80fd\u591f\u6ee1\u8db3\u4e0d\u540c\u573a\u5408\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/p>\n<\/p>\n<p><p>logging\u6a21\u5757\u7684\u57fa\u672c\u7528\u6cd5\u975e\u5e38\u7b80\u5355\u3002\u4f7f\u7528logging.basicConfig()\u51fd\u6570\u53ef\u4ee5\u5feb\u901f\u8bbe\u7f6e\u65e5\u5fd7\u7684\u8f93\u51fa\u683c\u5f0f\u548c\u7ea7\u522b\u3002\u6b64\u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570\uff0c\u5982filename\u3001level\u3001format\u7b49\uff0c\u5206\u522b\u7528\u4e8e\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u540d\u3001\u65e5\u5fd7\u7ea7\u522b\u548c\u65e5\u5fd7\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u8981\u5c06\u6240\u6709INFO\u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>logging.basicConfig(filename=&#39;example.log&#39;, level=logging.INFO)<\/p>\n<p>logging.info(&#39;This is an info message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u5c06&quot;INFO&quot;\u7ea7\u522b\u53ca\u4ee5\u4e0a\u7684\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230\u540d\u4e3aexample.log\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u65e5\u5fd7\u7ea7\u522b<\/strong><\/p>\n<\/p>\n<p><p>logging\u6a21\u5757\u63d0\u4f9b\u4e86\u591a\u4e2a\u65e5\u5fd7\u7ea7\u522b\uff1aDEBUG\u3001INFO\u3001WARNING\u3001ERROR\u3001CRITICAL\u3002\u6bcf\u4e2a\u7ea7\u522b\u90fd\u5bf9\u5e94\u4e0d\u540c\u7684\u4e25\u91cd\u7a0b\u5ea6\u3002DEBUG\u7ea7\u522b\u6700\u4f4e\uff0cCRITICAL\u7ea7\u522b\u6700\u9ad8\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65e5\u5fd7\u7ea7\u522b\u3002<\/p>\n<\/p>\n<ul>\n<li>DEBUG\uff1a\u8be6\u7ec6\u4fe1\u606f\uff0c\u901a\u5e38\u53ea\u5728\u8bca\u65ad\u95ee\u9898\u65f6\u4f7f\u7528\u3002<\/li>\n<li>INFO\uff1a\u786e\u8ba4\u4e00\u5207\u6309\u9884\u671f\u5de5\u4f5c\u3002<\/li>\n<li>WARNING\uff1a\u6307\u793a\u67d0\u4e9b\u4e0d\u671f\u671b\u7684\u4e8b\u60c5\u53d1\u751f\uff0c\u4f46\u8f6f\u4ef6\u4ecd\u7ee7\u7eed\u8fd0\u884c\u3002<\/li>\n<li>ERROR\uff1a\u7531\u4e8e\u66f4\u4e25\u91cd\u7684\u95ee\u9898\uff0c\u8f6f\u4ef6\u672a\u80fd\u6267\u884c\u67d0\u4e9b\u529f\u80fd\u3002<\/li>\n<li>CRITICAL\uff1a\u4e25\u91cd\u9519\u8bef\uff0c\u8868\u660e\u7a0b\u5e8f\u672c\u8eab\u53ef\u80fd\u65e0\u6cd5\u7ee7\u7eed\u8fd0\u884c\u3002<\/li>\n<\/ul>\n<p><p>\u4f8b\u5982\uff0c\u8981\u4ec5\u8bb0\u5f55WARNING\u7ea7\u522b\u53ca\u4ee5\u4e0a\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logging.basicConfig(level=logging.WARNING)<\/p>\n<p>logging.warning(&#39;This is a warning message&#39;)<\/p>\n<p>logging.error(&#39;This is an error message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u914d\u7f6e LOGGING \u683c\u5f0f<\/p>\n<\/p>\n<p><p>\u65e5\u5fd7\u683c\u5f0f\u7684\u914d\u7f6e\u53ef\u4ee5\u4f7f\u65e5\u5fd7\u4fe1\u606f\u66f4\u52a0\u6e05\u6670\u660e\u4e86\uff0c\u4fbf\u4e8e\u5206\u6790\u548c\u8c03\u8bd5\u3002\u901a\u8fc7logging\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u5b9a\u4e49\u65e5\u5fd7\u7684\u8f93\u51fa\u683c\u5f0f\uff0c\u5305\u62ec\u65f6\u95f4\u3001\u65e5\u5fd7\u7ea7\u522b\u3001\u6d88\u606f\u5185\u5bb9\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u81ea\u5b9a\u4e49\u683c\u5f0f<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u8c03\u7528logging.basicConfig()\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7format\u53c2\u6570\u81ea\u5b9a\u4e49\u65e5\u5fd7\u683c\u5f0f\u3002\u5e38\u7528\u7684\u683c\u5f0f\u5316\u7b26\u53f7\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li>%(asctime)s\uff1a\u65e5\u5fd7\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u95f4\u3002<\/li>\n<li>%(levelname)s\uff1a\u65e5\u5fd7\u7ea7\u522b\u540d\u79f0\u3002<\/li>\n<li>%(message)s\uff1a\u65e5\u5fd7\u6d88\u606f\u3002<\/li>\n<\/ul>\n<p><p>\u4f8b\u5982\uff0c\u8981\u8bb0\u5f55\u65e5\u5fd7\u7684\u65f6\u95f4\u3001\u7ea7\u522b\u548c\u6d88\u606f\uff0c\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logging.basicConfig(format=&#39;%(asctime)s - %(levelname)s - %(message)s&#39;)<\/p>\n<p>logging.warning(&#39;This is a warning message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u8f93\u51fa\u7c7b\u4f3c\u4ee5\u4e0b\u683c\u5f0f\u7684\u65e5\u5fd7\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code>2023-10-10 12:00:00 - WARNING - This is a warning message<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9ad8\u7ea7\u683c\u5f0f<\/strong><\/p>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u683c\u5f0f\u5316\u7b26\u53f7\u5916\uff0clogging\u6a21\u5757\u8fd8\u652f\u6301\u66f4\u9ad8\u7ea7\u7684\u683c\u5f0f\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728\u65e5\u5fd7\u4e2d\u6dfb\u52a0\u6a21\u5757\u540d\u3001\u51fd\u6570\u540d\u548c\u884c\u53f7\u7b49\u4fe1\u606f\uff0c\u4ee5\u4fbf\u66f4\u8be6\u7ec6\u5730\u8ffd\u8e2a\u65e5\u5fd7\u6765\u6e90\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logging.basicConfig(format=&#39;%(asctime)s - %(name)s - %(levelname)s - %(message)s&#39;)<\/p>\n<p>logger = logging.getLogger(__name__)<\/p>\n<p>logger.warning(&#39;This is a warning message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u8f93\u51fa\u7c7b\u4f3c\u4ee5\u4e0b\u683c\u5f0f\u7684\u65e5\u5fd7\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code>2023-10-10 12:00:00 - __m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__ - WARNING - This is a warning message<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u9009\u62e9\u65e5\u5fd7\u8f93\u51fa\u4f4d\u7f6e<\/p>\n<\/p>\n<p><p>Python\u7684logging\u6a21\u5757\u5141\u8bb8\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u591a\u4e2a\u4f4d\u7f6e\uff0c\u5305\u62ec\u63a7\u5236\u53f0\u3001\u6587\u4ef6\u3001\u751a\u81f3\u662f\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\uff0c\u9009\u62e9\u5408\u9002\u7684\u65e5\u5fd7\u8f93\u51fa\u4f4d\u7f6e\u53ef\u4ee5\u5e2e\u52a9\u66f4\u597d\u5730\u7ba1\u7406\u548c\u5206\u6790\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8f93\u51fa\u5230\u63a7\u5236\u53f0<\/strong><\/p>\n<\/p>\n<p><p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0clogging\u6a21\u5757\u4f1a\u5c06\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002\u8fd9\u79cd\u65b9\u5f0f\u9002\u5408\u5728\u5f00\u53d1\u548c\u8c03\u8bd5\u9636\u6bb5\u4f7f\u7528\uff0c\u53ef\u4ee5\u5feb\u901f\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logging.basicConfig(level=logging.INFO)<\/p>\n<p>logging.info(&#39;This is an info message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8f93\u51fa\u5230\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u6587\u4ef6\u662f\u6700\u5e38\u89c1\u7684\u65b9\u5f0f\u4e4b\u4e00\u3002\u901a\u8fc7\u6307\u5b9abasicConfig()\u51fd\u6570\u7684filename\u53c2\u6570\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u65e5\u5fd7\u6587\u4ef6\u7684\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logging.basicConfig(filename=&#39;logfile.log&#39;, level=logging.DEBUG)<\/p>\n<p>logging.debug(&#39;This is a debug message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u65e5\u5fd7\u6587\u4ef6\u7684\u8def\u5f84\u53ef\u4ee5\u662f\u76f8\u5bf9\u8def\u5f84\u6216\u7edd\u5bf9\u8def\u5f84\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8f93\u51fa\u5230\u591a\u4e2a\u4f4d\u7f6e<\/strong><\/p>\n<\/p>\n<p><p>logging\u6a21\u5757\u8fd8\u652f\u6301\u5c06\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230\u591a\u4e2a\u4f4d\u7f6e\u3002\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u591a\u4e2aHandler\u5bf9\u8c61\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff0c\u65e2\u8981\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u53c8\u8981\u8f93\u51fa\u5230\u6587\u4ef6\uff0c\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<h2><strong>\u521b\u5efalogger\u5bf9\u8c61<\/strong><\/h2>\n<p>logger = logging.getLogger(&#39;my_logger&#39;)<\/p>\n<p>logger.setLevel(logging.DEBUG)<\/p>\n<h2><strong>\u521b\u5efa\u63a7\u5236\u53f0Handler<\/strong><\/h2>\n<p>console_handler = logging.StreamHandler()<\/p>\n<p>console_handler.setLevel(logging.DEBUG)<\/p>\n<h2><strong>\u521b\u5efa\u6587\u4ef6Handler<\/strong><\/h2>\n<p>file_handler = logging.FileHandler(&#39;my_log.log&#39;)<\/p>\n<p>file_handler.setLevel(logging.ERROR)<\/p>\n<h2><strong>\u5b9a\u4e49\u65e5\u5fd7\u683c\u5f0f<\/strong><\/h2>\n<p>formatter = logging.Formatter(&#39;%(asctime)s - %(name)s - %(levelname)s - %(message)s&#39;)<\/p>\n<p>console_handler.setFormatter(formatter)<\/p>\n<p>file_handler.setFormatter(formatter)<\/p>\n<h2><strong>\u5c06Handler\u6dfb\u52a0\u5230logger<\/strong><\/h2>\n<p>logger.addHandler(console_handler)<\/p>\n<p>logger.addHandler(file_handler)<\/p>\n<h2><strong>\u8f93\u51fa\u65e5\u5fd7<\/strong><\/h2>\n<p>logger.debug(&#39;This is a debug message&#39;)<\/p>\n<p>logger.error(&#39;This is an error message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cDEBUG\u7ea7\u522b\u53ca\u4ee5\u4e0a\u7684\u65e5\u5fd7\u4fe1\u606f\u4f1a\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u800cERROR\u7ea7\u522b\u53ca\u4ee5\u4e0a\u7684\u4fe1\u606f\u5219\u540c\u65f6\u8f93\u51fa\u5230\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u521b\u5efa\u81ea\u5b9a\u4e49\u65e5\u5fd7\u8bb0\u5f55\u5668<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u901a\u5e38\u9700\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u65e5\u5fd7\u8bb0\u5f55\u5668\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u7ba1\u7406\u65e5\u5fd7\u4fe1\u606f\u3002logging\u6a21\u5757\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684API\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u521b\u5efa\u548c\u914d\u7f6e\u81ea\u5b9a\u4e49\u7684\u65e5\u5fd7\u8bb0\u5f55\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaLogger\u5bf9\u8c61<\/strong><\/p>\n<\/p>\n<p><p>Logger\u5bf9\u8c61\u662f\u65e5\u5fd7\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u4ef6\u4e4b\u4e00\uff0c\u8d1f\u8d23\u751f\u6210\u548c\u7ba1\u7406\u65e5\u5fd7\u8bb0\u5f55\u3002\u53ef\u4ee5\u901a\u8fc7logging.getLogger()\u51fd\u6570\u521b\u5efaLogger\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logger = logging.getLogger(&#39;my_logger&#39;)<\/p>\n<p>logger.setLevel(logging.INFO)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6eHandler<\/strong><\/p>\n<\/p>\n<p><p>Handler\u5bf9\u8c61\u8d1f\u8d23\u5c06\u65e5\u5fd7\u4fe1\u606f\u53d1\u9001\u5230\u6307\u5b9a\u7684\u8f93\u51fa\u4f4d\u7f6e\u3002\u5e38\u7528\u7684Handler\u5305\u62ecStreamHandler\uff08\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff09\u3001FileHandler\uff08\u8f93\u51fa\u5230\u6587\u4ef6\uff09\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">console_handler = logging.StreamHandler()<\/p>\n<p>file_handler = logging.FileHandler(&#39;my_log.log&#39;)<\/p>\n<p>logger.addHandler(console_handler)<\/p>\n<p>logger.addHandler(file_handler)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6eFormatter<\/strong><\/p>\n<\/p>\n<p><p>Formatter\u5bf9\u8c61\u7528\u4e8e\u5b9a\u4e49\u65e5\u5fd7\u7684\u8f93\u51fa\u683c\u5f0f\u3002\u53ef\u4ee5\u901a\u8fc7Formatter\u7c7b\u81ea\u5b9a\u4e49\u65e5\u5fd7\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">formatter = logging.Formatter(&#39;%(asctime)s - %(name)s - %(levelname)s - %(message)s&#39;)<\/p>\n<p>console_handler.setFormatter(formatter)<\/p>\n<p>file_handler.setFormatter(formatter)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f<\/strong><\/p>\n<\/p>\n<p><p>\u521b\u5efaLogger\u5bf9\u8c61\u5e76\u914d\u7f6e\u597dHandler\u548cFormatter\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528Logger\u7684debug()\u3001info()\u3001warning()\u3001error()\u3001critical()\u7b49\u65b9\u6cd5\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logger.info(&#39;This is an info message&#39;)<\/p>\n<p>logger.error(&#39;This is an error message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u65e5\u5fd7\u8f6e\u8f6c\u4e0e\u5907\u4efd<\/p>\n<\/p>\n<p><p>\u5728\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u65e5\u5fd7\u6587\u4ef6\u53ef\u80fd\u4f1a\u53d8\u5f97\u975e\u5e38\u5e9e\u5927\u3002\u4e3a\u4e86\u7ba1\u7406\u65e5\u5fd7\u6587\u4ef6\u7684\u5927\u5c0f\uff0clogging\u6a21\u5757\u63d0\u4f9b\u4e86\u65e5\u5fd7\u8f6e\u8f6c\u548c\u5907\u4efd\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528RotatingFileHandler<\/strong><\/p>\n<\/p>\n<p><p>RotatingFileHandler\u53ef\u4ee5\u5728\u65e5\u5fd7\u6587\u4ef6\u8fbe\u5230\u4e00\u5b9a\u5927\u5c0f\u65f6\u81ea\u52a8\u521b\u5efa\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u5907\u4efd\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from logging.handlers import RotatingFileHandler<\/p>\n<p>logger = logging.getLogger(&#39;my_logger&#39;)<\/p>\n<p>handler = RotatingFileHandler(&#39;my_log.log&#39;, maxBytes=2000, backupCount=5)<\/p>\n<p>logger.addHandler(handler)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5f53my_log.log\u6587\u4ef6\u7684\u5927\u5c0f\u8fbe\u52302000\u5b57\u8282\u65f6\uff0c\u65e5\u5fd7\u4f1a\u88ab\u8f6e\u8f6c\uff0c\u6700\u591a\u4fdd\u75595\u4e2a\u5907\u4efd\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528TimedRotatingFileHandler<\/strong><\/p>\n<\/p>\n<p><p>TimedRotatingFileHandler\u53ef\u4ee5\u6839\u636e\u65f6\u95f4\u95f4\u9694\u8fdb\u884c\u65e5\u5fd7\u8f6e\u8f6c\u3002\u4f8b\u5982\uff0c\u6bcf\u5929\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from logging.handlers import TimedRotatingFileHandler<\/p>\n<p>logger = logging.getLogger(&#39;my_logger&#39;)<\/p>\n<p>handler = TimedRotatingFileHandler(&#39;my_log.log&#39;, when=&#39;midnight&#39;, interval=1, backupCount=7)<\/p>\n<p>logger.addHandler(handler)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u65e5\u5fd7\u6587\u4ef6\u4f1a\u5728\u6bcf\u4e2a\u5348\u591c\u8f6e\u8f6c\u4e00\u6b21\uff0c\u6700\u591a\u4fdd\u75597\u5929\u7684\u65e5\u5fd7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u8fdc\u7a0b\u65e5\u5fd7\u8bb0\u5f55<\/p>\n<\/p>\n<p><p>\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u6216\u9700\u8981\u96c6\u4e2d\u7ba1\u7406\u65e5\u5fd7\u7684\u573a\u5408\uff0c\u8fdc\u7a0b\u65e5\u5fd7\u8bb0\u5f55\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002Python\u7684logging\u6a21\u5757\u652f\u6301\u5c06\u65e5\u5fd7\u4fe1\u606f\u53d1\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528SocketHandler<\/strong><\/p>\n<\/p>\n<p><p>SocketHandler\u53ef\u4ee5\u5c06\u65e5\u5fd7\u4fe1\u606f\u901a\u8fc7\u7f51\u7edc\u53d1\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u9700\u8981\u5728\u670d\u52a1\u5668\u7aef\u8bbe\u7f6e\u4e00\u4e2aSocketServer\u6765\u63a5\u6536\u65e5\u5fd7\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from logging.handlers import SocketHandler<\/p>\n<p>logger = logging.getLogger(&#39;my_logger&#39;)<\/p>\n<p>handler = SocketHandler(&#39;localhost&#39;, 9000)<\/p>\n<p>logger.addHandler(handler)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u65e5\u5fd7\u4fe1\u606f\u4f1a\u901a\u8fc7\u5957\u63a5\u5b57\u53d1\u9001\u5230localhost\u76849000\u7aef\u53e3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528HTTPHandler<\/strong><\/p>\n<\/p>\n<p><p>HTTPHandler\u53ef\u4ee5\u5c06\u65e5\u5fd7\u4fe1\u606f\u901a\u8fc7HTTP\u534f\u8bae\u53d1\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u9700\u8981\u5728\u670d\u52a1\u5668\u7aef\u8bbe\u7f6e\u4e00\u4e2aHTTP\u670d\u52a1\u5668\u6765\u63a5\u6536\u65e5\u5fd7\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from logging.handlers import HTTPHandler<\/p>\n<p>logger = logging.getLogger(&#39;my_logger&#39;)<\/p>\n<p>handler = HTTPHandler(&#39;http:\/\/localhost:9000&#39;, &#39;\/log&#39;, method=&#39;POST&#39;)<\/p>\n<p>logger.addHandler(handler)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u65e5\u5fd7\u4fe1\u606f\u4f1a\u901a\u8fc7HTTP POST\u8bf7\u6c42\u53d1\u9001\u5230<a href=\"http:\/\/localhost:9000\/log%E3%80%82\">http:\/\/localhost:9000\/log\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u65e5\u5fd7\u8bb0\u5f55\u7684\u6700\u4f73\u5b9e\u8df5<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Python\u8fdb\u884c\u65e5\u5fd7\u8bb0\u5f55\u65f6\uff0c\u9075\u5faa\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u597d\u5730\u7ba1\u7406\u548c\u5206\u6790\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u65e5\u5fd7\u7ea7\u522b<\/strong><\/p>\n<\/p>\n<p><p>\u6839\u636e\u5e94\u7528\u7a0b\u5e8f\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65e5\u5fd7\u7ea7\u522b\u3002DEBUG\u7ea7\u522b\u901a\u5e38\u7528\u4e8e\u5f00\u53d1\u9636\u6bb5\uff0c\u800cINFO\u6216WARNING\u7ea7\u522b\u9002\u7528\u4e8e\u751f\u4ea7\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u6301\u65e5\u5fd7\u683c\u5f0f\u4e00\u81f4<\/strong><\/p>\n<\/p>\n<p><p>\u4fdd\u6301\u4e00\u81f4\u7684\u65e5\u5fd7\u683c\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u5206\u6790\u548c\u8c03\u8bd5\u65e5\u5fd7\u4fe1\u606f\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u5305\u542b\u65f6\u95f4\u3001\u65e5\u5fd7\u7ea7\u522b\u3001\u6a21\u5757\u540d\u548c\u6d88\u606f\u5185\u5bb9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5408\u7406\u914d\u7f6e\u65e5\u5fd7\u8f6e\u8f6c\u548c\u5907\u4efd<\/strong><\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5408\u7406\u914d\u7f6e\u65e5\u5fd7\u8f6e\u8f6c\u548c\u5907\u4efd\u53ef\u4ee5\u9632\u6b62\u65e5\u5fd7\u6587\u4ef6\u53d8\u5f97\u8fc7\u4e8e\u5e9e\u5927\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u81ea\u5b9a\u4e49Logger<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u590d\u6742\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528\u81ea\u5b9a\u4e49Logger\u53ef\u4ee5\u66f4\u597d\u5730\u7ba1\u7406\u65e5\u5fd7\u4fe1\u606f\u3002\u53ef\u4ee5\u4e3a\u4e0d\u540c\u6a21\u5757\u521b\u5efa\u4e0d\u540c\u7684Logger\uff0c\u4ee5\u4fbf\u4e8e\u8ffd\u8e2a\u65e5\u5fd7\u6765\u6e90\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u4fdd\u65e5\u5fd7\u5b89\u5168<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u8bb0\u5f55\u654f\u611f\u4fe1\u606f\u65f6\uff0c\u8981\u6ce8\u610f\u65e5\u5fd7\u7684\u5b89\u5168\u6027\u3002\u907f\u514d\u5728\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u654f\u611f\u6570\u636e\uff0c\u5982\u5bc6\u7801\u3001\u8eab\u4efd\u8bc1\u53f7\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u7684\u8be6\u7ec6\u8bb2\u89e3\uff0c\u76f8\u4fe1\u60a8\u5bf9Python\u65e5\u5fd7\u8bb0\u5f55\u6709\u4e86\u66f4\u6df1\u5165\u7684\u4e86\u89e3\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u80fd\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u5b9e\u73b0\u548c\u7ba1\u7406\u65e5\u5fd7\u8bb0\u5f55\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u7684\u8f93\u51fa\u683c\u5f0f\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>logging<\/code>\u6a21\u5757\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u7684\u8f93\u51fa\u683c\u5f0f\u3002\u901a\u8fc7<code>basicConfig()<\/code>\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6307\u5b9a\u65e5\u5fd7\u7684\u683c\u5f0f\uff0c\u4f8b\u5982\u65f6\u95f4\u6233\u3001\u65e5\u5fd7\u7ea7\u522b\u548c\u6d88\u606f\u5185\u5bb9\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">import logging\n\nlogging.basicConfig(filename=&#39;app.log&#39;, \n                    level=logging.DEBUG, \n                    format=&#39;%(asctime)s - %(levelname)s - %(message)s&#39;)\n\nlogging.info(&#39;This is an info message.&#39;)\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u4f1a\u5c06\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230<code>app.log<\/code>\u6587\u4ef6\u4e2d\uff0c\u5e76\u5305\u542b\u65f6\u95f4\u3001\u65e5\u5fd7\u7ea7\u522b\u548c\u6d88\u606f\u5185\u5bb9\u3002<\/p>\n<p><strong>\u5982\u4f55\u63a7\u5236\u65e5\u5fd7\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u548c\u6587\u4ef6\uff1f<\/strong><br \/>\u4e3a\u4e86\u540c\u65f6\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u548c\u6587\u4ef6\uff0c\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u5904\u7406\u5668\u3002\u4f7f\u7528<code>StreamHandler<\/code>\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u4f7f\u7528<code>FileHandler<\/code>\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u6587\u4ef6\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import logging\n\nlogger = logging.getLogger(&#39;my_logger&#39;)\nlogger.setLevel(logging.DEBUG)\n\nfile_handler = logging.FileHandler(&#39;app.log&#39;)\nconsole_handler = logging.StreamHandler()\n\nformatter = logging.Formatter(&#39;%(asctime)s - %(levelname)s - %(message)s&#39;)\nfile_handler.setFormatter(formatter)\nconsole_handler.setFormatter(formatter)\n\nlogger.addHandler(file_handler)\nlogger.addHandler(console_handler)\n\nlogger.info(&#39;This message goes to both console and file.&#39;)\n<\/code><\/pre>\n<p>\u8fd9\u6837\u8bbe\u7f6e\u540e\uff0c\u65e5\u5fd7\u5c06\u540c\u65f6\u5728\u63a7\u5236\u53f0\u548c\u6307\u5b9a\u7684\u65e5\u5fd7\u6587\u4ef6\u4e2d\u663e\u793a\u3002<\/p>\n<p><strong>\u5982\u4f55\u6839\u636e\u65e5\u5fd7\u7ea7\u522b\u8fc7\u6ee4\u8f93\u51fa\u7684\u65e5\u5fd7\u4fe1\u606f\uff1f<\/strong><br \/>\u5728Python\u7684<code>logging<\/code>\u6a21\u5757\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\u6765\u8fc7\u6ee4\u8f93\u51fa\u7684\u65e5\u5fd7\u4fe1\u606f\u3002\u5e38\u7528\u7684\u7ea7\u522b\u6709DEBUG\u3001INFO\u3001WARNING\u3001ERROR\u548cCRITICAL\u3002\u53ef\u4ee5\u5728<code>basicConfig()<\/code>\u4e2d\u8bbe\u7f6e\u7ea7\u522b\uff0c\u4ee5\u4ec5\u8f93\u51fa\u7279\u5b9a\u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import logging\n\nlogging.basicConfig(filename=&#39;app.log&#39;, level=logging.WARNING)\n\nlogging.debug(&#39;This debug message will not be shown.&#39;)\nlogging.info(&#39;This info message will not be shown.&#39;)\nlogging.warning(&#39;This is a warning message.&#39;)\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ea\u6709WARNING\u7ea7\u522b\u53ca\u4ee5\u4e0a\u7684\u65e5\u5fd7\u4fe1\u606f\u4f1a\u88ab\u5199\u5165\u5230<code>app.log<\/code>\u6587\u4ef6\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6\u7684\u6838\u5fc3\u6b65\u9aa4\u5305\u62ec\u4f7f\u7528logging\u6a21\u5757\u3001\u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\u3001\u914d\u7f6e\u65e5\u5fd7\u683c\u5f0f\u3001\u9009\u62e9\u65e5\u5fd7\u8f93\u51fa\u4f4d\u7f6e [&hellip;]","protected":false},"author":3,"featured_media":1021299,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1021295"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1021295"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1021295\/revisions"}],"predecessor-version":[{"id":1021302,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1021295\/revisions\/1021302"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1021299"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1021295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1021295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1021295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}