Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling .info logging in nLog

Tags:

c#

nlog

In my .net application I am using nLog for logging ,now I want to disable .info logging (ie .error and .fatal log feature sholud be enabled) is there any option exists for that? plz help

like image 390
Sreejith G Avatar asked Jun 15 '12 18:06

Sreejith G


People also ask

How do I disable logging in NLog?

As of today, you can use maxlevel=Off to disable a logger.

Is NLog logger thread safe?

It is written everywhere that NLOG is thread-safe, but I've come through a few posts that dig things further and claim that this depends on the utilization scenario. What about my case ? I have to create thousands of loggers (not all at the same time, but still at a very high pace).

What is Basedir in NLog?

${basedir} — Directory where the application runs, aka. AppDomain.BaseDirectory.

Which of the following logging levels does NLog support?

NLog supports the following levels: Trace - Very detailed log messages, potentially of a high frequency and volume. Debug -Less detailed and/or less frequent debugging messages. Info - Informational messages.


1 Answers

You can set up the minimum log levels in the rules section of the nlog config in your app.config file. So for example, the following will configure nlog so that only warnings and above (which includes errors and fatals, but not info or trace) will be logged to a target named 'file':

<nlog>
  <rules>
    <logger name="*" minlevel="Warn" writeTo="file" />
  </rules>
</nlog>
like image 110
Marty Avatar answered Oct 18 '22 04:10

Marty