Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set LogLevel to error in log4net for hangfire

We have a web application and we are using log4net for logging. Recently I installed hangfire and now my log table (sqlserver db) is full of log enteries from hangfire. I want to minimise this to error and exceptions only. I believe I can set it by setting LogLevel to error but where exactly I need to do that.

Thanks

like image 356
Arshya Avatar asked May 02 '16 14:05

Arshya


People also ask

Where do I put log4net in web config?

Now, add the section "<log4net></log4net>" after the <configSections/> element in your app. config file. Next, inside the "<log4net></log4net>" section, place the configuration details as shown in the code snippet given below. That's all you need to do to configure log4net.

What are log4net Appenders?

For log4net to know where to store your log messages, you add one or more appenders to your configuration. An appender is a C# class that can transform a log message, including its properties, and persist it somewhere. Examples of appenders are the console, a file, a database, an API call, elmah.io, etc.

Does log4net support .NET core?

NET Standard (2.0. 7 and beyond). In fact, I can use Log4Net alongside the default logging API for . NET Core: Microsoft.


1 Answers

Add this logger to your web.config (log4net section)

<logger additivity="false" name="Hangfire">
   <level value="ERROR" />
   <appender-ref ref="HangfireLoggerAppender" />
</logger>
like image 186
Martino Bordin Avatar answered Oct 15 '22 10:10

Martino Bordin