Can logging a file seriously slow down your application?

I use Log4Net to write logs to files. Can this serioulsy slow down my application? I know that it depends on how much I write, but let me say that several hundred magazines can be written per second.

+4
source share
5 answers

This will slow down your application (obviously), but it depends a lot on your application if the slowdown is considered "serious." I think you need to let it work, and then decide if the performance is acceptable ...

+3
source

Of course it is possible.

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

If you register on another hard drive, everything will be better. If you check in via message-based transport, you'll probably be fine.

+4
source

Yes maybe. It is extremely important to consider the configuration, so you can configure it so that you don’t write so many logs, and then also have little overhead.

eg.

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

This will execute ToString only when necessary.

The fact that you need to write a magazine to disk when you turned it on - you cannot do much against it. But it’s usually not recommended to write too much magazine, because no one will ever read it.

+2
source

I am not sure about the slow application.

But I can say that if you write hundreds of logs per second, and this is also in one file, make sure that the synchronization of threads is in place, because you do not want crashes when several threads try to access one file.

+1
source

"Slow" is not binary. This is about what else you are doing.

If everything you do takes 10 times more wall clock time than logging, then logging will increase it by 10 percent: (10/10 + 1/10 = 1.1)

If everything you do takes 1/9 as much wall clock time as it takes to register, then the registration will increase 10 times: (1/1 + 9/1 = 10)

0
source

Source: https://habr.com/ru/post/1307635/


All Articles