Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Logging using FileHandler a bottleneck?

I am considering logging business events in a J2EE web application by using Java logging and FileHandler.

I am wondering whether that could cause a performance bottleneck, since many log records will be written to one file.

What are your experiences and opinions?

Is logging a busy web application to one file with Java logging and FileHandler likely to become performance bottleneck?

like image 945
TheLameProgrammer Avatar asked Dec 28 '22 20:12

TheLameProgrammer


1 Answers

It all depends on how much log statements you add. If you add logging after every line of code then performance will must certainly degrade.

Use logging for the important cases, set the correct logging level for your current purposes (testing or actual deployment) and use constructions like

if (Logger.isDebugEnabled()) {
   Logger.debug("Value is " + costlyOperation()")
}

to avoid calling code that is costly to run.

You might also want to check this article

like image 125
THelper Avatar answered Dec 30 '22 10:12

THelper