Does NLog have any sort of functionality to consolidate repetitive log messages when logging to a file?
Instead of:
09/08/2011 17:48:12 Your Foo hit a Bar
09/08/2011 17:48:13 Your Foo hit a Bar
09/08/2011 17:48:14 Your Foo hit a Bar
09/08/2011 17:48:15 Your Foo hit a Bar
09/08/2011 17:48:16 Your Foo hit a Bar
do this:
09/08/2011 17:48:12 Your Foo hit a Bar
09/08/2011 17:48:16 [4 additional messages just like the last one]
In the grand scheme of things, this is not a big deal — but it would help me cut down some of the ‘chattiness’ in our debugging logs.
Thanks!
There is no target in NLog which solves your issue out of the box. If you really need this, you would have to implement your own wrapper target which buffers the message for a short time (to detect the repitions) and passes it to the actual target.
If you have problems to analyze your log, you should either use a tool to filter the log or you should rethink your approach to logging. Is this information necessary? If yes, keep it as it is atm. The timestamps alone could be an useful inormation. If not, change your logging approach and log only useful information.