Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 much I'm writing away, but let's say that some hundreds of logs can be written per second.

like image 913
Lieven Cardoen Avatar asked Apr 22 '10 08:04

Lieven Cardoen


4 Answers

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...

like image 111
Stefan Egli Avatar answered Sep 23 '22 17:09

Stefan Egli


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.

like image 33
Oded Avatar answered Sep 22 '22 17:09

Oded


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.

like image 36
Stefan Steinegger Avatar answered Sep 19 '22 17:09

Stefan Steinegger


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.

like image 44
ckv Avatar answered Sep 23 '22 17:09

ckv