haddow64
haddow64

Reputation: 674

Nlog send by exchange

I am attempting to use NLog in a C# application that is deployed over a local domain.

Each user has an exchange mailbox and up until now I have been using Office.Interop with a basic logging class to send the results from their built in exchange account.

Is there any way to do something similar with NLog, I cant see anything in their documentation that would allow me to do this.

Upvotes: 0

Views: 334

Answers (1)

Stijn
Stijn

Reputation: 2060

You could use the NLog Mail Target in combination, with (a) the Windows Identity Layout Renderer (if you can construct the mailaddress from the logged in username)

<!-- In your NLog.config. -->
<target
    ...
    from="${windows-identity:domain=false}@yourcompany.com"
    ...>

or (b) the EventProperties Layout Renderer (formerly EventContext) to provide the mailaddress from your application.

/* In your code. */
LogEventInfo theEvent = new LogEventInfo(LogLevel.Debug, "", "Pass my custom value");

theEvent.Properties["MailAddress"] = theUsersMailAddress;
myLogger.Log(theEvent);
<!-- In your NLog.config. -->
<target
    ...    
    from="${event-properties:item=MailAddress}"
    ...>

Upvotes: 1

Related Questions