Take the 2-minute tour ×

I have been using NLog for a couple of months now, just logging to the Event Log, however that is not at all ideal in any scenario imho.

I am wondering, is it possible to create your own Program or Service log with NLog? It doesn't seem like it according to the list of supported targets over at http://nlog-project.org/wiki/Targets

Is anyone able to shed some light on this?

share|improve this question
Can you provide more info on what you are trying to do? –  Joe Jan 23 '13 at 14:44
add comment

1 Answer

You can totally create an application who store and show you all the logs of your other applications, but you may need to extend NLog, that's what i've done for my workplace. For example :

  1. Create a generic database who can store all the logs from NLog and other types of log if needed.

  2. Make a custom Layout Renderer who create a XML with your log info (I don't try XmlEncode LayoutRenderer at the time I make my system, I think it'll be great now)

  3. Find a way to send your XML through your network, I used Transactionnal MSMQ but only the non-transactionnal target exists in NLog, so I created (=copy-paste the original with some enhancement) my own target

  4. Create a service who receive your log's XML and insert them in the database

  5. Finally, create an app who use the database to show you what happened in your environnement

It's a strong solution if you have the time to do it. For our production environnement it save us many times. But It depend on what you need exactly

* EDIT 2013-01-25 : *

For creating your own log in the Applications and Services logs tree : See this post who explain how to create your own log and the event source that goes with

Nlog can also create an event source if he doesn't exist, but as you can see in this post the application need Read permission for the key :


Or you can simply run the application as an administrator.

Once you have created your own log and his event source, you can now use Nlog normally, with a config like that :

  <target xsi:type="EventLog" name="event" layout="${message}"
          machineName="." log="myLog" source="myEventSource"/>
  <logger name="myLogger" writeTo="event"/>

Hope it helps

share|improve this answer
I just wanted to make NLog set up a log under the "Program and Service" category in the Windows Eventviewer. –  Maritim Jan 24 '13 at 12:00
Sorry, I didn't understand your question. Have you tried to create a personal view in the "Applications and services" tree and use the view name with the parameter log in the EventLog target config ? –  rootoz Jan 24 '13 at 15:24
Yes, I've done it with the System.Diagnostiscs library, but I wish to achieve the same thing using NLog rather than System.Diagnostics –  Maritim Jan 25 '13 at 8:32
add comment

Your Answer


