{"id":2100,"date":"2023-09-11T13:22:19","date_gmt":"2023-09-11T04:22:19","guid":{"rendered":"https:\/\/www.itchefblog.com\/?p=2100"},"modified":"2023-09-11T13:22:19","modified_gmt":"2023-09-11T04:22:19","slug":"python%ec%9c%bc%eb%a1%9c-%eb%a7%8c%eb%93%a0-%ec%84%9c%eb%b9%84%ec%8a%a4%ec%97%90-%eb%a7%a4%ec%9d%bc-%ec%83%88%eb%a1%9c%ec%9a%b4-%eb%a1%9c%ea%b7%b8%ed%8c%8c%ec%9d%bc-%ec%83%9d%ec%84%b1","status":"publish","type":"post","link":"https:\/\/www.itchefblog.com\/?p=2100","title":{"rendered":"Python\uc73c\ub85c \ub9cc\ub4e0 \uc11c\ube44\uc2a4\uc5d0 \ub9e4\uc77c \uc0c8\ub85c\uc6b4 \ub85c\uadf8\ud30c\uc77c \uc0dd\uc131"},"content":{"rendered":"\n<p>python\uc73c\ub85c \ub9cc\ub4e0 \uac04\ub2e8\ud55c \uc11c\ube44\uc2a4\uc5d0 \ud30c\uc77c\ub85c \uac04\ub2e8\ud788 \ub85c\uae45\uc744 \ud574\uc57c\ud558\ub294 \uc77c\uc774 \uc0dd\uaca8\uc11c \uc815\ub9ac\ud574\ubcf8\ub2e4.<\/p>\n\n\n\n<p>Python\uc5d0\uc11c logging \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub85c\uadf8\ub97c \uc800\uc7a5\ud560 \uc218 \uc788\uc73c\uba70, TimedRotatingFileHandler\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub85c\uadf8 \ud30c\uc77c\uc744 \uc77c\uc790\ubcc4\ub85c \uc0dd\uc131\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport logging\nfrom logging.handlers import TimedRotatingFileHandler\nimport os\n\ndef setup_logging():\n    if not os.path.exists('logs'):\n        os.makedirs('logs')\n    \n    log_format = &quot;%(asctime)s - %(message)s&quot;\n    log_handler = TimedRotatingFileHandler(&quot;logs\/%Y-%m-%d.log&quot;, when=&quot;midnight&quot;, interval=1)\n    log_handler.suffix = &quot;%Y-%m-%d.log&quot;\n    log_handler.setFormatter(logging.Formatter(log_format))\n    \n    logger = logging.getLogger()\n    logger.setLevel(logging.INFO)\n    logger.addHandler(log_handler)\n    return logger\n\nlogger = setup_logging()\n\n#\ub85c\uae45\uc774 \ud544\uc694\ud55c \uacf3\uc5d0 \uc544\ub798\uc640 \uac19\uc774 \uc791\uc131\ud558\uba74 logs \ud3f4\ub354 \ud558\uc704\uc5d0 \ub9e4\uc77c \uc0c8\ub85c\uc6b4 \ud30c\uc77c\uba85\uc73c\ub85c \ub85c\uadf8\uac00 \uc313\uc774\uac8c \ub41c\ub2e4.\nlogger.info(&quot;This is logging messages&quot;)\n\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>python\uc73c\ub85c \ub9cc\ub4e0 \uac04\ub2e8\ud55c \uc11c\ube44\uc2a4\uc5d0 \ud30c\uc77c\ub85c \uac04\ub2e8\ud788 \ub85c\uae45\uc744 \ud574\uc57c\ud558\ub294 \uc77c\uc774 \uc0dd\uaca8\uc11c \uc815\ub9ac\ud574\ubcf8\ub2e4. Python\uc5d0\uc11c logging \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub85c\uadf8\ub97c \uc800\uc7a5\ud560 \uc218 \uc788\uc73c\uba70, TimedRotatingFileHandler\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub85c\uadf8 \ud30c\uc77c\uc744 \uc77c\uc790\ubcc4\ub85c \uc0dd\uc131\ud560 \uc218 \uc788\ub2e4.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[514,7,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2100"}],"collection":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2100"}],"version-history":[{"count":1,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2100\/revisions"}],"predecessor-version":[{"id":2101,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2100\/revisions\/2101"}],"wp:attachment":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}