{"id":99,"date":"2025-07-16T15:13:02","date_gmt":"2025-07-16T06:13:02","guid":{"rendered":"http:\/\/34.64.61.65\/?p=99"},"modified":"2025-07-16T15:13:02","modified_gmt":"2025-07-16T06:13:02","slug":"python-logger","status":"publish","type":"post","link":"https:\/\/hed-g.me\/?p=99","title":{"rendered":"Python Logger"},"content":{"rendered":"\n<ol class=\"wp-block-list\">\n<li>Logger<\/li>\n<\/ol>\n\n\n\n<p>\uc5b4\ub5a4 \ud504\ub85c\uadf8\ub7a8\uc774 \uc2e4\ud589\ub420 \ub54c \ubc1c\uc0dd\ud558\ub294 \uc774\ubca4\ud2b8\ub97c \ucd94\uc801, \ub85c\uadf8\ub97c \ucd9c\ub825\ud55c\ub2e4.<\/p>\n\n\n\n<p>1) Log Levels<\/p>\n\n\n\n<p>\uae30\ubcf8 \uc218\uc900\uc740 WARNING.<\/p>\n\n\n\n<p>(1) DEBUG(10):&nbsp; &nbsp;\uc790\uc138\ud55c \uc815\ubcf4\ub97c \uac16\uace0 \uc788\ub294 \ub85c\uadf8. \ubb38\uc81c \ud574\uacb0\uc2dc \ud544\uc694\ud558\uba74 \uc0ac\uc6a9.<\/p>\n\n\n\n<p>(2) INFO(20): \ud504\ub85c\uadf8\ub7a8\uc774 \uc608\uc0c1\ub300\ub85c \uc815\uc0c1 \uc791\ub3d9\ub418\uace0 \uc788\ub294\uc9c0 \ud655\uc778\ud560 \ub54c \uc0ac\uc6a9<\/p>\n\n\n\n<p>(3) WARNING(30): \uc608\uc0c1\uce58 \ubabb\ud55c \uc77c\uc774 \ubc1c\uc0dd, \ub610\ub294 \ucd94\ud6c4 \ubc1c\uc0dd\ud560 \ubb38\uc81c\ub97c \ud45c\uc2dc. \uc791\uc5c5\uc740 \uc815\uc0c1 \uc9c4\ud589.<\/p>\n\n\n\n<p>(4) ERROR(40): \uc2ec\uac01\ud55c \ubb38\uc81c\ub85c \uc778\ud574 \ud504\ub85c\uadf8\ub7a8\uc774 \uc77c\ubd80 \uae30\ub2a5\uc744 \uc218\ud589\ud558\uc9c0 \ubabb\ud558\uace0 \uc758\ub3c4\ud55c \uc815\uc0c1 \uae30\ub2a5\uc5d0 \ub3c4\ub2ec\ud558\uc9c0 \ubabb\ud568<\/p>\n\n\n\n<p>(5) CRITICAL(50): \ub354\uc6b1\uc2ec\uac01\ud55c \ubb38\uc81c\ub85c \ud504\ub85c\uadf8\ub7a8 \uc790\uccb4\uac00 \uc2e4\ud589\uc774 \uc5bc\ub9c8\ub4e0\uc9c0 \uc911\ub2e8\ub420 \uc218 \uc788\uc74c\uc744 \uc54c\ub9bc.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Logger \uc0ac\uc6a9\ubc95<\/li>\n<\/ol>\n\n\n\n<p>1) Log level<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ubaa8\ub4e0 \ub85c\uadf8\ub97c \ucd9c\ub825\ud558\uae30 \uc704\ud574 Log level\uc744 DEBUG\ub85c \uc124\uc815.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import logging\n\nlogging.basicConfig(level=logging.DEBUG)\nlogging.debug('View all logs')<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.kakaocdn.net\/dna\/b26TQ8\/btsowOQhmvE\/AAAAAAAAAAAAAAAAAAAAAN3wRE4D4Gg3z-XeRA5l9MBJpteqM4xv_hB_jYdiM52f\/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&amp;expires=1753973999&amp;allow_ip=&amp;allow_referer=&amp;signature=uMA85NXTcqq1lVYuTPsx9wD9aPE%3D\" alt=\"\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>2) Log Formatting<\/p>\n\n\n\n<p>\ub85c\uadf8 \uc774\ubca4\ud2b8\uc758 \ucd9c\ub825 format\uc744 \uc124\uc815.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ub85c\uadf8\uc5d0 \ud604\uc7ac \ub0a0\uc9dc\uc640 \uc2dc\uac04, \ub85c\uadf8 level, \ub85c\uadf8 \uba54\uc2dc\uc9c0 \ucd9c\ub825<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import logging\n\nlogging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s',\n                    datefmt='%m\/%d\/%Y %I:%M:%S %p',\n                    level=logging.DEBUG)\n\nlogging.debug('view all logs.')<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.kakaocdn.net\/dna\/eejoXv\/btsoyJtwWNe\/AAAAAAAAAAAAAAAAAAAAAF0pxNCc3-nEVk5yr5QHF9InRa3ut9FV7SbVrRE9EmC4\/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&amp;expires=1753973999&amp;allow_ip=&amp;allow_referer=&amp;signature=gzRAGMiF5Y0pXZAvl2yHpzv5YcQ%3D\" alt=\"\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>3) Logging<\/p>\n\n\n\n<p>(1) Logger \uc0dd\uc131<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import logging\n\nlog = logging.getLogger(\"test\")<\/code><\/pre>\n\n\n\n<p>(2) Logger Level \uc124\uc815<\/p>\n\n\n\n<p>\uc0dd\uc131\ud55c \ub85c\uac70 \uc778\uc2a4\ud134\uc2a4\uc5d0 \uac01\uac01 \ub85c\uadf8 level&nbsp; \uc9c0\uc815, \uc124\uc815\ud558\uc9c0 \uc54a\uc744 \uc2dc default \uac12 WARNING<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import logging\n\nlog = logging.getLogger(\"test\")\n\n#Logging Level \uc124\uc815\nlog.setLevel(logging.DEBUG)<\/code><\/pre>\n\n\n\n<p>(3) Handler \uc124\uc815<\/p>\n\n\n\n<p>\ucf58\uc194\ucc3d\uc5d0 \ucd9c\ub825\ud560\uc9c0\u00b7\ud30c\uc77c\ub85c \ub85c\uadf8\ub97c \uae30\ub85d\ud560\uc9c0 \uc124\uc815 \uac00\ub2a5.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>StreamHandler(): \ucf58\uc194 \ucd9c\ub825<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>streamHandler = logging.StreamHandler()\nlog.addHandler(streamhandler)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>FileHandler(): \ud30c\uc77c \ucd9c\ub825<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>filehandler = logging.FileHandler('test.log')\nlog.addHandler(filehandler)<\/code><\/pre>\n\n\n\n<p>(4) Formatting \uc124\uc815<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import logging\n\nlog = logging.getLogger(\"test\")\n\nlog.setLevel(logging.DEBUG)\n\n# Logging Formatting\nformatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')\n\nstreamhandler = logging.StreamHandler()\nstreamhandler.setFormatter(formatter)\nlog.addHandler(streamhandler)\n\nlog.debug('view all logs')<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc5b4\ub5a4 \ud504\ub85c\uadf8\ub7a8\uc774 \uc2e4\ud589\ub420 \ub54c \ubc1c\uc0dd\ud558\ub294 \uc774\ubca4\ud2b8\ub97c \ucd94\uc801, \ub85c\uadf8\ub97c \ucd9c\ub825\ud55c\ub2e4. 1) Log Levels \uae30\ubcf8 \uc218\uc900\uc740 WARNING. (1) DEBUG(10):&nbsp; &nbsp;\uc790\uc138\ud55c \uc815\ubcf4\ub97c \uac16\uace0 \uc788\ub294 \ub85c\uadf8. \ubb38\uc81c \ud574\uacb0\uc2dc \ud544\uc694\ud558\uba74 \uc0ac\uc6a9. (2) INFO(20): \ud504\ub85c\uadf8\ub7a8\uc774 \uc608\uc0c1\ub300\ub85c \uc815\uc0c1 \uc791\ub3d9\ub418\uace0 \uc788\ub294\uc9c0 \ud655\uc778\ud560 \ub54c \uc0ac\uc6a9 (3) WARNING(30): \uc608\uc0c1\uce58 \ubabb\ud55c \uc77c\uc774 \ubc1c\uc0dd, \ub610\ub294 \ucd94\ud6c4 \ubc1c\uc0dd\ud560 \ubb38\uc81c\ub97c \ud45c\uc2dc. \uc791\uc5c5\uc740 \uc815\uc0c1 \uc9c4\ud589. (4) ERROR(40): \uc2ec\uac01\ud55c \ubb38\uc81c\ub85c \uc778\ud574 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[50],"tags":[134,133],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-python","tag-python","tag-133"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/hed-g.me\/index.php?rest_route=\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hed-g.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hed-g.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hed-g.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hed-g.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=99"}],"version-history":[{"count":1,"href":"https:\/\/hed-g.me\/index.php?rest_route=\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/hed-g.me\/index.php?rest_route=\/wp\/v2\/posts\/99\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/hed-g.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hed-g.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hed-g.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}