<story><title>My Logging Best Practices (2020)</title><url>https://tuhrig.de/my-logging-best-practices/</url></story><parent_chain><item><author>ryandrake</author><text>One thing I noticed in one of the article&amp;#x27;s examples is that the log contained an example user&amp;#x27;s PII:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    INFO  | User registered for newsletter. [user=&amp;quot;Thomas&amp;quot;, email=&amp;quot;thomas@tuhrig.de&amp;quot;]
&lt;/code&gt;&lt;/pre&gt;
Ruh-roh! You now have a potential privacy incident ready to occur, if an inadvertent log leak ever happens. I think, at least these days, one vital component of any logging API is the ability to flag particular bits of information as PII so that it can get handled differently upon output, storage, or ingestion by other tools. For example, if the users&amp;#x27;s actual E-mail address is not specifically useful for debugging, do you need to display it in the default visualization of the log?&lt;p&gt;I think in 2020, with companies&amp;#x27; privacy practices getting more and more scrutiny, any logging best practices doc should at least mention treatment of PII.</text></item></parent_chain><comment><author>wpietri</author><text>Yuuup! I&amp;#x27;ve been looking through the Epik dump [1] and there&amp;#x27;s all sorts of PII where it shouldn&amp;#x27;t be. Logs for sure. Also object dumps as text fields. [2] And the most impressive mistake is logging every failed login attempt with the login and password. There are a ton of entries where people put the password in the username field and vice versa, so it&amp;#x27;s basically a big database of passwords of frequent users.&lt;p&gt;There are also a ton of tables where they made a backup copy of the table and just left it in the database for years. Ditto switching to new coce but not cleaning up the old data. So even data that would normally be removed due to, say, expiring domains ends up being preserved.&lt;p&gt;I recommend digging through it to anybody who is sad about the systems you run at work. It&amp;#x27;s such a fractal set of fuckups that I promise you&amp;#x27;ll feel better about your legacy systems.&lt;p&gt;[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;ddosecrets.com&amp;#x2F;wiki&amp;#x2F;Epik&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;ddosecrets.com&amp;#x2F;wiki&amp;#x2F;Epik&lt;/a&gt;&lt;p&gt;[2] in PHP serialization format: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;PHP_serialization_format&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;PHP_serialization_format&lt;/a&gt;</text></comment>
<story><title>My Logging Best Practices (2020)</title><url>https://tuhrig.de/my-logging-best-practices/</url></story><parent_chain><item><author>ryandrake</author><text>One thing I noticed in one of the article&amp;#x27;s examples is that the log contained an example user&amp;#x27;s PII:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    INFO  | User registered for newsletter. [user=&amp;quot;Thomas&amp;quot;, email=&amp;quot;thomas@tuhrig.de&amp;quot;]
&lt;/code&gt;&lt;/pre&gt;
Ruh-roh! You now have a potential privacy incident ready to occur, if an inadvertent log leak ever happens. I think, at least these days, one vital component of any logging API is the ability to flag particular bits of information as PII so that it can get handled differently upon output, storage, or ingestion by other tools. For example, if the users&amp;#x27;s actual E-mail address is not specifically useful for debugging, do you need to display it in the default visualization of the log?&lt;p&gt;I think in 2020, with companies&amp;#x27; privacy practices getting more and more scrutiny, any logging best practices doc should at least mention treatment of PII.</text></item></parent_chain><comment><author>mholt</author><text>Ah yeah, that&amp;#x27;s why in Caddy 2 while we do emit full details from HTTP requests in our structured JSON logs, you have the ability to traverse into each log message and replace or delete data within it: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;caddyserver.com&amp;#x2F;docs&amp;#x2F;caddyfile&amp;#x2F;directives&amp;#x2F;log#filter&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;caddyserver.com&amp;#x2F;docs&amp;#x2F;caddyfile&amp;#x2F;directives&amp;#x2F;log#filter&lt;/a&gt;</text></comment>