Log4net/Logging - What have you found to be useful

2019-03-08 00:45发布

I just started using Log4Net and was looking to see what you have found to be useful in your logging experiences.

What types of things have you found to be useful to log; what ended up being just noise; when do you use the different logging levels (DEBUG, INFO, etc); do you have a standard format for each log entry; are there things you ALWAYS log?

Any pitfalls? Good articles on logging in general?

Update: Where do you log to? What Appenders and why?

Thank you!

8条回答
我只想做你的唯一
2楼-- · 2019-03-08 01:33
  • All exceptions get logged at ERROR level at the highest level in the call stack that is possible (typically in event handlers etc)
  • User input that causes a problem gets logged at WARN level (because it might indicate that we need to improve our UI to better guide the user)
  • "Significant" activities get logged at INFO level (i.e. anything that involves billing a customer's credit card, queries to a third party API etc), including the data involved (typically XML serialized, with any sensitive information removed)
  • Very verbose activities might be logged at DEBUG level

We seldom use FATAL level logging.

We normally deploy with a RollingLogFileAppender at INFO level, and an SmtpAppender at ERROR level.

查看更多
祖国的老花朵
3楼-- · 2019-03-08 01:36

There's another log4net log viewer (other than the Apache Chainsaw) which my company has been using for some time, it's called "log4net Dashboard" and is being developed by a Norwegian company (I think) called FaktNet, it's website is http://www.l4ndash.com.

It provides a web based dashboard which is quite intuitive and provides a good overview on the log, can be used with many different appenders (such as rolling file or SQL-server appender) but it isn't free as the Apache Chainsaw is. They do have a developer's license though, which is free and allows local use only, which would be sufficient for example for a freelancer wanting to monitor his sites (a single l4n-dashboard can connect to multiple log-sources).

FaktNet has various licenses, depending on how many users are supposed to be able to access the dashboard, and their Enterprise license isn't really expensive (it's $600 I think). Given its ability to access multiple logs it can be a major asset to a development team that's developing and monitoring many medium to large scale websites.

查看更多
登录 后发表回答