NLog and Windows Service: not getting it to work

1,219 views
Skip to first unread message

Kire

unread,
Aug 13, 2013, 7:35:45 AM8/13/13
to nlog-...@googlegroups.com
Just trying to make a small service but can't get it to work
 
Service:
 
   public partial class Service1 : ServiceBase
    {
       private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
        public Service1()
        {
            InitializeComponent();
        }
        protected override void OnStart(string[] args)
        {
            logger.Info("Ruminant started");
        }
        protected override void OnStop()
        {
        }
    }
 
Config file:
 
<?xml version="1.0"?>
<configuration>
  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
      <target name="logfile" fileName="c:/test/rumi.log" xsi:type="File" />   
    </targets>
    <rules>
      <logger name="*" minlevel="Trace" writeTo="logfile"/>
    </rules>
  </nlog>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Starting up the service fails with an error 1920.
 
I must be missing something simple I guess. File permission on C:\Test folder are full control for anyone/anything. Config is present where service exe is installed.
 
Out of clues. Hope someone can point in a good direction.
 
Regards,
Erik
 

Kim Christensen

unread,
Aug 13, 2013, 8:37:02 AM8/13/13
to nlog-...@googlegroups.com
Could you try enabing the internal log as described here, https://github.com/NLog/NLog/wiki/Logging-troubleshooting#internal-logging, and post the output
Reply all
Reply to author
Forward
Message has been deleted
0 new messages