1

I'm using Log4j2 in a scala application but noticed that it loads several scripting engines to process its configuration using JSR 223 (see "Scripts" session in https://logging.apache.org/log4j/2.x/manual/configuration.html). We don't really need this functionality since our configuration is programmatically generated through scala code. We also noticed this has a quite high memory usage (more than 100MB) as it loads a javascript and a scala scripting engine. Is there a way to disable this through either a log4j configuration or some other Java knob? I haven't found one so far.

Thank you

  • I doubt log4j2 would take 100MB of memory to load something that doesn't exist. Which memory are you talking about? – Gaël J Jan 20 '22 at 06:58
  • I have measured when my scala application initializes log4j2 and it does use significantly more heap memory (+ 30 MB) while the overall container memory usage jumps by more than 100MB, which I guess comes from extra off-heap memory. After a bit more debugging, it seems like NOT passing -Dlog4j2.debug=true does avoid the huge increase in memory usage. There's something in the script manager in log4j that loads a lot more stuff in debug mode. – user16408944 Jan 26 '22 at 04:06

0 Answers0