什么是包括日志记录使用log4net的最佳实践? [英] What are the best practices for including logging using log4net?

查看:249
本文介绍了什么是包括日志记录使用log4net的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被告知要记录添加到我的code。使用log4net的,问题是没有人能够在时间旅行,看到了记录将需要用来解决什么实际问题。

I have been told to add "logging" to my code using log4net, the problem is no one can travel in time and see what real world problems the logging will need to be used to solve.

因此​​有一组guidlines反正,以什么来登录,从而获得一个合理的成本/收益权衡

Therefore is there a set of guidlines anyway as to what to log so as to get a reasonable cost/benefit trade off?

因此​​:

什么样的​​记录应该之一添加   到应用,将是有益   以后呢?

What kinds of logging should one add to an application that would be useful later?

(将code采用了大量的 WCF ,一边是在的WinForms,另一边是服务器,通常在同一台机器上运行)

(The code uses a lot of WCF, one side is in Winforms, the other side is a "server" that normally run on the same machine)

-

我已经例外AJM的回答做了有益的博客文章有大量的注释,它指向的,但如果有人来了一个漂亮的一套的拇指规则,我可能会改变预期的答案。

I have excepted AJM's answers to do the useful blog post with lot of comments it points to, but if someone comes up with a nice set of "rules of thumb" I am likely to change the expected answer.

推荐答案

我发现这篇文章非常有帮助:的 http://blog.codinghorror.com/the-problem-with-logging/

I found this article very helpful: http://blog.codinghorror.com/the-problem-with-logging/

在特别的,我认为一个最低限度的做法确实是要走的路。在过去,我已经试过登录太多,但这种涨大的code

In particular I think a minimalist approach is indeed the way to go. In the past I've tried to log too much but this bloats the code

另外的思考,更多的日志条目越好是错误的,因为它涨大的日志本身。我现在看测井公司主要好处是提供了立足的正在发生的事情或概述。如果有更多的细节需要特定领域那就这样吧,但是默认的位置应该是越少越好

Also the thinking that the more log entries the better is wrong because it bloats the logs themselves. I now look at loggings main benefit as providing a "foothold" or overview of what is going on. If more detail is needed for particular areas then so be it but the default position should be less is better

这篇关于什么是包括日志记录使用log4net的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆