ogun
ogun

Reputation: 1334

Useful log pattern/format?

I want to create a log file in my program.

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...

Upvotes: 1

Views: 2479

Answers (4)

Brook
Brook

Reputation: 6009

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

Upvotes: 5

Cos Callis
Cos Callis

Reputation: 5084

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.

Upvotes: 1

Denis Biondic
Denis Biondic

Reputation: 8201

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

Upvotes: 1

Paul Sonier
Paul Sonier

Reputation: 39480

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.

Upvotes: 3

Related Questions