Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nlog: send mail when Loglevel >= Loglevel.Error with last x messages

Tags:

nlog

I'd like to do this (from log4net docu) with nlog:

This example shows how to deliver only significant events. A LevelEvaluator is specified with a threshold of WARN. This means that an email will be sent for each WARN or higher level message that is logged. Each email will also contain up to 512 (BufferSize) previous messages of any level to provide context. Messages not sent will be discarded.

Is it possible?

I only found this on codeproject. But it uses a wrapper target that flushes in behalf of the number of messages, not on the log level.

Thanks Tobi

like image 436
sqltobi Avatar asked Sep 13 '12 14:09

sqltobi


1 Answers

There is a QueuedTargetWrapper ( a target that buffers log events and sends them in batches to the wrapped target) that seems address the requirement. I haven't tried it yet.

There is a related discussion "The Benefits of Trace Level Logging in Production Without the Drawback of Enormous Files"

like image 153
Michael Freidgeim Avatar answered Oct 13 '22 07:10

Michael Freidgeim