Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用这个简单的字符串编写一个自定义日志文件,但是 log.msg 会从脚本中写入所有事件。如何制作第三个自定义日志文件?(log.err、log.msg、log.custom)?
你见过日志模块吗?它允许您同时登录多个文件。或者你只是从标准输出重定向输出?在这种情况下,您可以将 sys.stdout 设置为您自己的StringIO子类,并覆盖 write 方法以写入多个文件。