NLog quits at midnight

6 messages Options
Embed this post
Permalink
JSearles

NLog quits at midnight

Reply Threaded More More options
Print post
Permalink
I am using NLog using the .Net Compact Framework 2 on a device running CE 5.0. The logging works fine until midnight and then it stops logging. Below is a copy of the config file i am using.

  <targets>
    <target xsi:type="File"
            name="file"
            fileName="${basedir}\logs\${logger}log.txt"
            layout="${logname} ${longdate} ${message}" />
  </targets>

  <rules>
    <logger name="*" writeTo="file" />
  </rules>

This is using NLog 1. Any assistance will be appreciated.

Thanks,

Josh
Andrew Stone-2

Re: NLog quits at midnight

Reply Threaded More More options
Print post
Permalink
Hmmm strange.. have you tried to turn on internal logging?

From the docs:
  • <nlog throwExceptions="true" />- adding throwExceptions attribute in the config file causes NLog not to mask exceptions and pass them to the calling application instead. This attribute is useful at deployment time to quickly locate any problems. It's recommended to turn throwExceptions to "false" as soon as the application is properly configured to run, so that any accidental logging problems won't crash the application.
  • <nlog internalLogFile="file.txt" />- adding internalLogFile cause NLog to write its internal debugging messages to the specified file. This includes any exceptions that may be thrown during logging.
  • <nlog internalLogLevel="Trace|Debug|Info|Warn|Error|Fatal" /> - determines internal log level. The higher the level, the less verbose the internal log output.
hope this helps.

Cheers,
Andrew.



2009/2/24 JSearles <[hidden email]>

I am using NLog using the .Net Compact Framework 2 on a device running CE
5.0. The logging works fine until midnight and then it stops logging. Below
is a copy of the config file i am using.

 <targets>
   <target xsi:type="File"
           name="file"
           fileName="${basedir}\logs\${logger}log.txt"
           layout="${logname} ${longdate} ${message}" />
 </targets>

 <rules>
   <logger name="*" writeTo="file" />
 </rules>

This is using NLog 1. Any assistance will be appreciated.

Thanks,

Josh
--
View this message in context: http://n2.nabble.com/NLog-quits-at-midnight-tp2377358p2377358.html
Sent from the NLog-list mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list



--
Kind regards,
----------------------------------------
Andrew Stone
Microsoft .NET Consultant

AndrewStone.net
[hidden email]
http://www.andrewstone.net
+61 (0)412 488 251
----------------------------------------

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
JSearles

Re: NLog quits at midnight

Reply Threaded More More options
Print post
Permalink
Thanks! I'll try this and let you know how it goes.

Josh
JSearles

Re: NLog quits at midnight

Reply Threaded More More options
Print post
Permalink
In reply to this post by Andrew Stone-2
Below is the error that came up in the NLog log file. I'm guessing that the first write to a log after midnight triggers the archiving process? It seems like that is the root of the problem.


2009-02-27 00:00:57.0000 Error Target exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at System.String.Substring()
at NLog.Targets.FileTarget.SequentialArchive()
at NLog.Targets.FileTarget.DoAutoArchive()
at NLog.Targets.FileTarget.Write()
at NLog.LoggerImpl.Write()
at NLog.Logger.WriteToTargets()
at NLog.Logger.Trace()
at Ai.Logger.Trace()
at Ai.TaskHandler.Reset()
at Ai.CellForm.CellForm_GotFocus()
at System.Windows.Forms.Control.OnGotFocus()
at System.Windows.Forms.Control.WnProc()
at System.Windows.Forms.ContainerControl.WnProc()
at System.Windows.Forms.Form.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at Ai.MainMenu.Main()
JSearles

Re: NLog quits at midnight

Reply Threaded More More options
Print post
Permalink
I just noticed that i put up the wrong version of the log configuration i am using. Below is what i am using.


<?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"
      throwExceptions="true"
      internalLogFile="nlog.txt"
      internalLogLevel="Debug">

  <targets>
    <target xsi:type="File"
            name="file"
            fileName="${basedir}\logs\${logger}log.txt"
            layout="${logname} ${longdate} ${message}"
            archiveEvery="Day"
            archiveFileName="${basedir}\logs\archive\${logger}log_${shortdate}.txt"
            maxArchiveFiles="5" />
  </targets>

  <rules>
    <logger name="*" writeTo="file" />
  </rules>
</nlog>
JSearles

Re: NLog quits at midnight

Reply Threaded More More options
Print post
Permalink
OK, this ended up being because i was using ${shortdate} in the filename. This should've created a legal filename, but removing this from the archive filename solved the problem.

Josh