What are the best practices for logging an enterpr

2019-03-08 10:29发布

What are some logging standards for an enterprise application?

Does anyone have any white papers on this topic?

标签: logging
6条回答
聊天终结者
2楼-- · 2019-03-08 11:09

A good article is written on this at Effective logging practices ease enterprise development.

The crux is:

  1. Know the need of logging.
  2. Understand the options available and which suits you best (varies with Platform/OS/etc)
  3. Plan the strategy in advance before implementation.
  4. Keep reviewing the make changes.
查看更多
我想做一个坏孩纸
3楼-- · 2019-03-08 11:13

See the Microsoft Enterprise Library. It includes the Logging Application Block and that documentation might be what you are looking for. You can see the MSDN Documentation without having to install the library first. Specifically, see Key Scenarios and Design of the Logging Application Block to answer your question (maybe even if you are not using .NET).

UPDATE (April 23, 2013) See Embracing Semantic Logging using the new Semantic Logging Application Block

查看更多
孤傲高冷的网名
4楼-- · 2019-03-08 11:19

There are tons of logging frameworks out there including log4net and log4j, but the right one for you will depend on your platform and system.

The best logging techniques will depend largely on your platform and the design of your system. You need to know/decide how much information you need to diagnose a particular type of problem. Generally, you should instrument your code in a way that does not require a lot of code repetition or modification. Logging frameworks in .NET that use Attributed classes and methods are a good example of low-impact instrumentation. You should also be able to modify the level of logging (Low through Verbose) through configuration without having to shut down or restart any services.

查看更多
聊天终结者
5楼-- · 2019-03-08 11:19

If you really want to dive into philosophy on the subject, try "Do Not Believe in Structured Logging" on Miloslav Trmač's blog.

"...these lessons were learned the hard way..."

查看更多
叛逆
6楼-- · 2019-03-08 11:31

Some tips :

  • log no more than necessary in release/production
  • log error ever, if possible make this :
    • put log operation in temp var (vector/list)
    • at the end if no errors occurs, discard logs, in another case send to log file
  • create flag to control level of info to log
  • control log behavior in production/development environment
  • control concurrency access at log file
  • control how much long file log is need
  • control how much time file log should be maintained
  • sometimes is need to perform performance verification, put timers where necessary
查看更多
劳资没心,怎么记你
7楼-- · 2019-03-08 11:31

Serilog is another structured logging solution that has become popular since the question was first asked.

In his interview, Mr. Blumhardt talks about building the library as a result of going through the pain of logging that we have all experienced. They talk on the show about simple logging during initial development and formalizing logging as the project matures. Good stuff and may add to the best practices knowledge base brought up in the question.

From the website:

Like other logging libraries for .NET, Serilog provides diagnostic logging to files, the console, and so-on. It is easy to set up, has a clean API, and is portable between recent .NET platforms.

Unlike other logging libraries for .NET, Serilog is built with structured log data in mind. Parameters passed along with log messages are not destructively rendered into a text format. Instead, they're preserved as structured data that can be written in document form to a NoSQL data store

查看更多
登录 后发表回答