英文:
Disable logs from 3rd party libraries in Go
问题
我想禁用自定义日志包中的各种第三方库的日志记录。我无法直接修改这些库或者日志包。我已经查看了https://stackoverflow.com/questions/38831816/disable-logging-for-3rd-party-library,其中建议重新定义os.Stderr
为自定义的io.Writer
。我该如何实现这里描述的方法:https://stackoverflow.com/a/38832115/18024985?
英文:
I want to disable logs from various 3rd party libraries which a custom log package. I'm not able to modify the libraries directly or the log package. I've already looked at https://stackoverflow.com/questions/38831816/disable-logging-for-3rd-party-library which suggests to redefine os.Stderr
as a custom io.Writer
. How do I implement the approach described here: https://stackoverflow.com/a/38832115/18024985?
答案1
得分: 2
你所指的问题描述了一个与你的情况不同的情况,其中使用了自定义的日志记录器。在你的情况下,使用标准的日志记录器,你应该使用log.SetOutput
而不是重定向os.Stderr
。
英文:
The question you have pointed to describes a different situation from yours, where a custom logger is being used. In your case, with the standard logger, you should use log.SetOutput
rather than redirecting os.Stderr
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论