擅长:python、mysql、java
<p><strong>你的节目的目标受众是什么?</strong></p>
<p><strong>如果您正在创建一个桌面应用程序,而大多数用户无法阅读日志,则应该为他们处理日志。</strong>不仅要旋转日志,还要删除旧日志-您不想填满可怜用户的硬盘!在</p>
<p>另一方面,如果读者是有经验的UNIX系统管理员,则必须采用不同的方法。在</p>
<p><strong>系统管理员将需要您无法预料的功能。</strong>通过电子邮件发送它们,将它们写入仅附加存储,这是您可以命名的。对于这些用户来说,最好是尽可能灵活地记录日志。Flexible(在UNIX中)意味着简单-所以只需写入一个文件并认为它已经完成。在</p>
<p>而且,<strong>系统管理员不想重新学习如何重新记录日志</strong>。即使您想提供这种特性,也要确保默认值在这个假设范围内是合理的。在</p>
<p>最后。tdelaney提出了一个重要的观点:标准<code>FileHandler</code>没有太多关注它要写入的文件。您应该使用一个<a href="https://docs.python.org/2/library/logging.handlers.html#watchedfilehandler" rel="noreferrer">WatchedFileHandler</a>,它是专门为此而编写的</p>