开发者

Useful log pattern/format?

I want to create a log file in my prog开发者_如何学Goram.

My log pattern should contain: Log type, Datetime, Thread Name, Method Name, Log detail.. etc...

Which log pattern do you suggest?

Does any accepted log pattern for this? For example "trace log pattern", "event log pattern" etc...


Use a logging library such as NLog or Log4Net Then you can tweak the layout & renderers all you want without changing code or recompiling, and have lots of other useful functionality as well (such as rolling logs, db/network/email appenders, filters, log levels etc).

A good comparison of some logging frameworks


I REALLY recommend using Log4net; it supports almost everything you'd possibly want to do, is almost freakishly robust, and very straightforward to put in place.

You can find it here.


Why don't you try a logging framework like Log4Net ? There are plenty of tutorials around...


The Microsoft Application Blocks have some very good boiler plate code you can start with. The Logging Application Block can be used by itself, with other MAB elements or simply as a starting point for rolling your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜