Thursday, January 30, 2014

.NET low latency logging. Part 3 - log4net performance

Add log4net to the sample application

It is also very simple to integrate log4net into the sample application. Just add log4net package (current version is 1.2.13) with a NuGet to the project.

Add <log4net> section to the App.config file

Create a logger in code.

NullAppender

Note that log4net doesn't have Null appender out from the box. But it is not difficult to create it by inheriting from AppenderSkeleton with an empty void Append(LoggingEvent loggingEvent) override method:

Performance hints

My experiments showed the following key options that influence on log4net performance out of the box:
  • NullAppender that was implemented above is the fastest appender. It shows the general performance of logging internals and can be used to compare log4net with other similar components (e.g. NLog).
  • FileAppender is used to store logging messages to the specified file, but performs much slower than NullAppender
  • RollingFileAppender is usefull to separate logging messages by date, time or file size attribute, but performs a little bit slower than FileAppender

Performance of the NullAppender


Performance of the FileAppender and RollingFileAppender


Conclusions


1 comment:

  1. You need to take part in a contest for the most effective blogs on the web. I'll suggest this website! play casino

    ReplyDelete