There isn't a Timeout
or similar property on any of the FileAppender
types. I looked at the source for the appender and it's not doing anything special (there's a crazy path from the file appender to the appender skeleton into the actual message layout type to see all the stream writing).
I have two recommendations...
Custom appender to the rescue!
You could try to write a custom appender that includes all sorts of protection from the network (NetworkFileAppender
has a nice ring to it). But you'd have to really consider the design. Appenders in log4net are supposed to be synchronous and fast.
Take a look at a post I wrote about performance appending with log4net. It's full of caveats and flaws. Notice particularly the part where I came back and said not to write your own asychronous appender :)
That leads me to my second recommendation
Shared logging "service"
An old post about asynchronous file appending on the log4net mailing list ended with this recommendation
I would suggest using a shared buffer with a single worker thread that logs the buffer once it reaches a certain size.
This service should be separate from your main application (maybe just a background thread). It should include all the protection from the network, which probably includes another local file store (unless you're ok losing messages).
The BlockingCollection in .NET 4.0 and the Task library could help you spin something up to get the ideas down.
Conclusion (and real recommendation)
I question your decision to append to a network file store in the first place. You're essentially adding network calls all over your application (the longest and least-guaranteed kind of call possible). It's also probably not worth the effort to implement any of these "fixes". Ask why you need the files on the network store and see if another solution can satisfy your real needs.