I use NLog to send emails when an exception occurs in my application. Here is part of my goal:
<target xsi:type="Mail" name="email" subject="${level}:" .. >
I get emails with topics such as "Error:" or "Fatal:". This works fine, but I want to add Exception.Message to the subject line
Is it possible to configure custom properties in NLog. I cannot figure out how to do this, so just to understand what I want here is an example of what I'm trying to do:
m_oLogger.Fatal( oException.BuildMessage(), new {MyMessage=oException.Message});
* Note: BuildMessage () is just an extension method for converting all the details of an exception (including internal exceptions) to a readable string
And for my purpose:
<target xsi:type="Mail" name="email" subject="${level}: ${Custom.MyMessage}" .. >
Then I would receive emails with topics such as:
Fatal: Syntax error in parameters or arguments. Server response: Account does not exist
Is such flexibility possible in NLog? If not, do you know about other .NET registration platforms that offer such functionality?
source share