<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>logging - MyApollo</title><link>https://myapollo.com.tw/en/tags/logging/</link><description>All 1 MyApollo articles and notes about “logging”.</description><generator>Hugo</generator><language>en-US</language><copyright>Copyright (c) 2020-2026 MyApollo</copyright><lastBuildDate>Wed, 30 Aug 2023 16:17:15 +0800</lastBuildDate><atom:link href="https://myapollo.com.tw/en/tags/logging/index.xml" rel="self" type="application/rss+xml"/><item><title>Introduction to a Handy Python Package - structlog</title><link>https://myapollo.com.tw/en/blog/python-structlog/</link><pubDate>Wed, 30 Aug 2023 16:17:15 +0800</pubDate><guid>https://myapollo.com.tw/en/blog/python-structlog/</guid><category>Python Module Recommendations</category><category>Python Programming - Beginner Level</category><description>&lt;p&gt;When starting with Python&amp;rsquo;s &lt;a href="https://docs.python.org/3/library/logging.html"&gt;logging&lt;/a&gt; module, many of us have encountered confusion, as with the following code example:&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;import logging&#10;&#10;log = logging.getLogger(__name__)&#10;log.info('Hello')&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;We might expect this code to print the string &lt;code&gt;Hello&lt;/code&gt;, but it doesn&amp;rsquo;t.&lt;/p&gt;&#10;&lt;p&gt;This is because the default log level for Python&amp;rsquo;s logging module is &lt;code&gt;WARNING&lt;/code&gt;, so only messages at &lt;code&gt;WARNING&lt;/code&gt;, &lt;code&gt;ERROR&lt;/code&gt;, or &lt;code&gt;CRITICAL&lt;/code&gt; levels are displayed.&lt;/p&gt;&#10;&lt;p&gt;To properly use the &lt;a href="https://docs.python.org/3/library/logging.html"&gt;logging&lt;/a&gt; module, setting it up is necessary, which often means consulting the Python documentation. This isn&amp;rsquo;t a problem with Python per se, but rather a design philosophy difference.&lt;/p&gt;&#10;&lt;p&gt;So, is there a package more intuitive and easier to use than the built-in &lt;a href="https://docs.python.org/3/library/logging.html"&gt;logging&lt;/a&gt; module?&lt;/p&gt;&#10;&lt;p&gt;The answer is &amp;ldquo;yes,&amp;rdquo; and that is the &lt;a href="https://www.structlog.org/en/stable/index.html"&gt;structlog&lt;/a&gt; package, which this article introduces.&lt;/p&gt;</description></item></channel></rss>