Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Skeletal Windows Service which blocks on NLog
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns=""
<target xsi:type="Debugger" name="debugger_target" />
<target xsi:type="Chainsaw" name="chainsaw_target" address="udp4://localhost:4141"/>
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
<logger name="*" minlevel="Trace" writeTo="chainsaw_target"/>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace WindowsService1
public partial class Service1 : ServiceBase
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public Service1()
protected override void OnStart(string[] args)
logger.Trace("Service1 started.");
protected override void OnStop()
logger.Trace("Service1 stopped.");

This comment has been minimized.

Copy link

@dojo90 dojo90 commented Dec 13, 2016

This is not working on my App. Do you have any solutions for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment