代码记录比? [英] Code to logging ratio?

查看:110
本文介绍了代码记录比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是理想的代码记录比率?我不习惯写日志,因为我开发的大多数应用程序没有太多日志记录。



最近,我改变了工作,注意到您无法看到调用log4net的应用程序代码。我知道这是有用的,但肯定有太多的调试语句是一样糟糕,因为没有任何东西。



有记录语句告诉你什么时候每个方法开始并完成和他们返回。



有一些插件在编译时使用反射添加logging语句并不容易,所以他们没有得到在你试图看代码的方式?



在这些天,强大的IDE和远程调试是很多日志记录真正nescisary吗?

解决方案

实际上有一个很好的库,用于在你说, PostSharp 。它允许你通过基于属性的编程,除了记录之外的许多其他非常有用的东西。



我同意你说的是一个有点过量的日志。 / p>

有些人提出了一些好处,尤其是银行业务情景和其他关键任务应用程序。可能需要进行极端日志记录,或者至少能够在需要时打开和关闭,或者设置各种级别。


What is the ideal code to logging ratio? I'm not used to writing logs as most of the applications I've developed have not had much logging.

Recently though I've changed job, and I've noticed that you can't see the application code for the calls to log4net. I appreciate that this is useful but surely having too many debug statements is just as bad as not having any at all?

There are logging statements that tell you when every method starts and finishes and what they are returning. and when pretty much anything is done.

Would it not be easier to have some addon that used reflection to add the logging statements in at compile time so they didn't get in the way as you were trying to look at the code?

Also in these days of powerful IDEs and remote debugging is that much logging really nescisary?

解决方案

There is actually a nice library for adding in logging after the fact as you say, PostSharp. It lets you do it via attribute-based programming, among many other very useful things beyond just logging.

I agree that what you say is a little excessive for logging.

Some others bring up some good points, especially the banking scenario and other mission critical apps. It may be necessary for extreme logging, or at least be able to turn it on and off if needed, or have various levels set.

这篇关于代码记录比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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