Help with Error and Fatal logging

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Help with Error and Fatal logging

mtod
I'm new to Nlog so far it looks very good.

I built a Windows Service and inserted a few calls to the NLog to test it out.

//-----------------------------

        private static Logger logger = LogManager.GetCurrentClassLogger();

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            string opt = null;
            logger.Trace("FMI Windows Service - Enter Main");
            logger.Info("Info Msg");
            logger.Error("Test Error");
            logger.Fatal("Fatal Error");
            logger.Debug("Debug Msg");
//------------------------------

So far the Trace, Info and Debug work fine.

The Error and Fatal give me a dialog box with an debug assertion failed error and stops the service.

I'm not sure where this is coming from the other routines work fine.

Thanks for any help
//-------------------------------

---- DEBUG ASSERTION FAILED ----
---- Assert Short Message ----
2012-08-31 10:25:37.6686 Fatal Error
---- Assert Long Message ----

   at NLog.Targets.TraceTarget.Write(LogEventInfo logEvent)
   at NLog.Targets.Target.Write(AsyncLogEventInfo logEvent)
   at NLog.Targets.Target.WriteAsyncLogEvent(AsyncLogEventInfo logEvent)
   at NLog.LoggerImpl.WriteToTargetWithFilterChain(TargetWithFilterChain targetListHead, LogEventInfo logEvent, AsyncContinuation onException)
   at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targets, LogEventInfo logEvent, LogFactory factory)
   at NLog.Logger.WriteToTargets[T](LogLevel level, IFormatProvider formatProvider, T value)
   at NLog.Logger.Fatal(String message)
   at FMIWinService.Program.Main(String[] args) in f:\Users\mtod\My Documents\My Development Projects\FMIWinService\FMIWinService\Program.cs:line 28
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

//-----------------------------------
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with Error and Fatal logging

Jason LaFlair
Administrator
What's your config look like?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with Error and Fatal logging

mtod
<?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"
      autoReload="true"
      throwExceptions="true"
      internalLogFile="nlog.log">

 
  <targets>
   
   
    <target xsi:type="Trace" name="TraceLog" layout="${longdate} ${message} ${exception:format=tostring}"/>
    <target xsi:type="NLogViewer" name="Sentinel" layout="${longdate} ${message} ${exception:format=tostring}" address="udp://192.168.1.110:9999" />
    <target xsi:type="EventLog" name="EventLog" layout="${longdate} ${message} ${exception:format=tostring}" />
    <target xsi:type="Mail"
          name="smtpMail"
          layout="${longdate} ${message} ${exception:format=tostring}"  
          subject="${machinename} Event Notification"
          to="xxxx@xxxxxxx.com"
          from="sftp@xxxxxxx.com"
          smtpUserName="sftp@xxxxxxx.com"
          smtpPassword="XXXXXX"
          smtpAuthentication="Basic"
          smtpServer="smtp.xxxxxx.com"
          smtpPort="999" />
  </targets>
     
  <rules>
   
    <logger name="*" minlevel="Trace" writeTo="Sentinel" />
    <logger name="*" minlevel="Trace" writeTo="TraceLog" />
    <logger name="*" minlevel="Trace" maxlevel="Fatal" writeTo="EventLog" />
    <logger name="*" minlevel="Error" maxlevel="Fatal" writeTo="smtpMail" />
  </rules>   
</nlog>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help with Error and Fatal logging

Jason LaFlair
Administrator
My first idea would be to remove your SMTP target and see if you are still getting the error.   At least pinpoint it down to the target.

Then if it's the smtp - double/triple check the values.

Jason.
Loading...