When are log4net messages flushed from the buffer to the destination?

时间:2016-02-12 19:37:11

标签: log4net

I'm using the default ADONetAppender. The buffer size value is set to 100. As far as I understand, messages will be held in memory until there are 100. Then they will be flushed to their destination. Here are my questions.

1.What if only ten messages get placed into the buffer all day. Will they ever get flushed to their destination? 2. If I'm logging from a web application, what happens when there are 50 messages in the buffer and the application pool recycles, or the web application gets republished? Do those 50 messages get lost forever? 3. Is it inefficient to just set the buffer size to 1? We always set it to 1 when testing so we can see the logs ASAP.

Thanks in advance.

1 个答案:

答案 0 :(得分:0)

  1. 不,直到达到缓冲区计数或应用程序结束。

  2. 当应用程序域被拆除时,缓冲区将刷新到数据库

  3. 这只意味着每个日志事件有一个数据库连接,这可能是一个很高的开销(并阻塞调用线程)。如果您查看this answer,那么ADONetAppender子类的示例将在指定时间后将缓冲区刷新到数据库。