Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Skeletal Windows Service which blocks on NLog
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<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}" />
-->
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="chainsaw_target"/>
</rules>
</nlog>
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()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
logger.Trace("Service1 started.");
}
protected override void OnStop()
{
logger.Trace("Service1 stopped.");
}
}
}
@dojo90

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