Monday, May 21, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Coding horror deadlock
Prev Next
You are not authorized to post a reply.

Author Messages
koger

12/05/2008 12:55 PM  


Hi

Those of you who reads coding horror, might have seen this post:
http://www.codinghorror.com/blog/archives/001192.html.

Could somebody explain me how this deadlock happend? And how do I avoid to
get any deadlocks myself using log4net?

Reineri, Jim

12/05/2008 2:47 PM  

This is the situation described in Coding Horror:
        On thread #1, our code was doing Log (lock) / DB stuff (lock)
        On thread #2, our code was doing DB stuff (lock) / log stuff (lock)

The is a classic deadlock example.  If thread #1 locks 'Log' at the same time that thread #2 locks 'DB Stuff' then thread #1 will be waiting for the 'DB stuff' lock to be freed before it can complete its work and thread #2 will be waiting for the 'Log' lock to be freed before completing its work.  Because each is waiting on the other, neither will ever release its lock.

It is more likely to occur on heavily loaded, multi-core systems.

This problem is easily avoided by making sure that any code that needs both resources applies the locks in the same order.

As was pointed out in the article, the problem was not a problem with log4net.  It really is not a even problem with logging.  The problem was really bad code.

The author does make some good points about logging.  While I do not necessarily agree with everything he said, it is worth a read.

Cheers,
Jim

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Coding horror deadlock



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement