开发者

Can writing to logfiles seriously slow down your application?

I'm using Log4Net to write logs to files. Can this serioulsy slow down my application? I know it depends on how mu开发者_如何学运维ch I'm writing away, but let's say that some hundreds of logs can be written per second.


It will slow down your application (obviously) but it depends a lot on your application if the slow down qualifies as "serious". I think you need to let it run and then decide if the performance is acceptable...


Of course it can.

As you already said, it depends on how you write it.

If you are logging to a different hard-drive, things will be better. If you are logging via a message based transport, you will probably be OK.


Yes it can. It is crucial to consider the configuration, so you can configure it to not write that much log and then also not have much overhead.

eg.

if (logger.IsDebugEnabled)
{
  logger.DebugFormat("log: {0}", myObject.ToString());
}

This will execute ToString only if needed.

The fact that you need to write the log to the disk when you enabled it - you can't do much against it. But usually it is not useful to write too much log, because nobody will ever read it anyway.


I am not sure regarding the slowness of application.

But i can say that if you are writing hundreds of logs per second and that too into a same file then make sure that thread synchronization is in place because you dont want crashes when multiple threads try to access same file.


"Slow" is not a binary property. It's relative to what else you're doing.

If whatever else you're doing takes 10 times as much wall-clock time as the logging, then logging will increase it by 10 percent: (10/10 + 1/10 = 1.1)

If whatever else you're doing takes 1/9 as much wall-clock time as the logging, then logging will increase it by 10 times: (1/1 + 9/1 = 10)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜