Created
July 8, 2012 22:59
-
-
Save aggieben/3073339 to your computer and use it in GitHub Desktop.
Skeletal Windows Service which blocks on NLog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not working on my App. Do you have any solutions for me?