Giter VIP home page Giter VIP logo

log4net.async's Introduction

Log4Net.Async

Build status

This library provides asynchronous Log4Net logging. Application performance is improved by performing message appending I/O operations on one or more background threads.

Forwarding appenders augment or otherwise alter the behavior of other appenders. In this case logging operations are buffered or queued until the background thread is available to forward log messages to another appender or appenders. This allows the thread that is creating log messages to continue rather than waiting on I/O operations.

Multiple forwarding appenders may be configured, each having its own set of appenders, dedicated message queue, and background appending thread. This enables parallel appending while maintaining message sequence.

Version 2.X Release Notes

  • AsyncAdoAppender and AsyncRollingFileAppender have been removed after being obsolete for a while. The Forwarding appenders are a much better solution.
  • BufferSize config value was not working due to nullable type conversion, see #13

Testimonials

If you find this library useful, please give us some feedback and any details about performance gains you may have measured. Thanks in advance!

Forwarding Appenders

###AsyncForwardingAppender

This appender utilizes a ring buffer with a a default limit of 1000 messages. If the head of the buffer overtakes the tail, message loss occurs. This behavior prioritizes application performance over logging fidelity. The current implementation uses a 10ms polling (sleep) period on the background thread.

Configuration wraps one of more appenders as shown in the following configuration example:

<appender name="rollingFile" type="log4net.Appender.RollingFileAppender">
	...
</appender>

<appender name="adoNet" type="log4net.Appender.AdoNetAppender">
	...
</appender>

<appender name="asyncForwarder" type="Log4Net.Async.AsyncForwardingAppender,Log4Net.Async">
	<appender-ref ref="rollingFile" />
	<appender-ref ref="adoNet" />
</appender>

<root>
	<appender-ref ref="asyncForwarder" />
</root>

###ParallelForwardingAppender

This appender utilizes System.Collections.Concurrent.BlockingCollection(T) and other facets of the Task Parallel Library (TPL) to implement a lossless message queue. This implementation does not use polling but rather waits until new messages are available to append. This results in less CPU overhead for queue polling and appending starts without having to wait on sleep expiration.

The default queue size is 1000 messages. If the queue fills as a result of the rate of message creation exceeding the rate of appending, threads creating messages will block, as they would if they were not using the ParallelForwardingAppender.

Configuration wraps one of more appenders as shown in the following configuration example:

<appender name="rollingFile" type="log4net.Appender.RollingFileAppender">
	...
</appender>

<appender name="adoNet" type="log4net.Appender.AdoNetAppender">
	...
</appender>

<appender name="asyncForwarder" type="Log4Net.Async.ParallelForwardingAppender,Log4Net.Async">
	<appender-ref ref="rollingFile" />
	<appender-ref ref="adoNet" />
</appender>

<root>
	<appender-ref ref="asyncForwarder" />
</root>

Notes

If the Log4Net.Async library is only referenced in non-code (eg. a log4net log.config file), then the VS build process will not automatically copy the Log4Net.Async dll to the build folder for projects that reference other projects using Log4Net.Async. This occurs even if Copy Local is set to "True".

To get around this some of our users have created a dummy class whose sole purpose is to extend the RingBuffer class, without actually doing anything or being used anywhere at all.

If anyone has an elegant solution to this please let me know or submit a pull request.

log4net.async's People

Contributors

rcollette avatar johndroach avatar

Watchers

James Cloos avatar DY avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.