Stopping the trace target showing messagebox on Error logs

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

Stopping the trace target showing messagebox on Error logs

Wob
Hi,

When I enable the 'trace' target I'm finding that messages logged to Error (logger.Error('...')) are being displayed in a pop-up dialog with Abort, Retry, and Ingore buttons.

Is NLog displaying this dialog? Does anybody know how to disable this dialog?

Thx

Rob Smyth
Wob
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping the trace target showing messagebox on Error logs

Wob
I wonder if anybody else is seeing this problem?

Does anybody else get message boxes appearing for Error and Fatal log messages when logging is enabled?

Rob Smyth
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping the trace target showing messagebox on Error logs

bezpal
yeah I can see it too.
Any way to disable it?

Anybody with experience?
Thanks!

Here is the code:
App.Config>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
        <section
          name="nlog"
          type="NLog.Config.ConfigSectionHandler, NLog"/>
  </configSections>


  <nlog >
        <targets>
          <target name="console" type="Console" layout="${date:format=HH\:MM\:ss} ${logger} ${message}"/>
          <target name="trace" type="Trace" layout="${date:format=HH\:MM\:ss} ${logger} ${message}"/>
          <target name="file" type="File" fileName="c:\ActiveMessageUnitTest_Nlog.log"/>
        </targets>

        <rules>
          <logger name="*" minlevel="Trace" writeTo="trace" />
          <logger name="*" minlevel="Trace" writeTo="console" />
         
        </rules>
  </nlog>
 
</configuration>
<<<<<<<<<<<<<<<<<<<<<<<<<<

Program.cs >>>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Diagnostics;
using NLog;

namespace Test
{
        class Program
        {
                private static Logger logger = LogManager.GetCurrentClassLogger();

                static void Main(string[] args)
                {
       
                        logger.Error("logger");

                }
        }
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping the trace target showing messagebox on Error logs

bezpal
I got it! :)
NLog does:
            if (logEvent.Level >= LogLevel.Error)
            {      Trace.Fail(CompiledLayout.GetFormattedMessage(logEvent));        }
            else
            {      Trace.WriteLine(CompiledLayout.GetFormattedMessage(logEvent));    }
 

To prevent Trace.Fail from opening messagebox set
  <system.diagnostics>
        <trace>
                <listeners>
                        <remove name="Default" />
            </listeners>
        </trace>
  </system.diagnostics>

Or write your own tracing target
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping the trace target showing messagebox on Error logs

Drac2000
In reply to this post by Wob
Or Just add this element in the app.config under system.diagnostics element :
<assert assertuienabled="false" />

drac
Loading...