0

What is the command or steps to set Dlog4j2.formatMsgNoLookups=true across an entire server (vm)

I found this command for applying to a specific var java -Dlog4j2.formatMsgNoLookups=true -jar myapp.jar

but have been asked to deploy it across the entire OS not just to a single jar

As its not a redhat OS variable, its part of Java, and I am not Java experienced I am not sure, it doesn't seem to be in any config file.

On windows I understand it is a simple regedit, so does that mean it needs to go in bash profile as a env var or similar?

EDIT the answer from elsewhere, incase someone else is looking is export _JAVA_TOOL_OPTIONS= -Dlog4j2.formatMsgNoLookups=true

for tomcat its CATALINA_OPTS

which may be found inside catalina.sh

hat
  • 1
  • 2
  • It's an environment variable, log4j2.formatMsgNoLookups. You will have to restart your java apps for it to take effect – adnan_e Dec 13 '21 at 09:02
  • restarting is fine but can you give me the exact syntax to add? like is is just export Dlog4j2.formatMsgNoLookups=true ? or is there something extra like export _JAVA_TOOL_OPTIONS= -Dlog4j2.formatMsgNoLookups=true – hat Dec 13 '21 at 09:11

1 Answers1

2

You can put JAVA_TOOL_OPTIONS environment variable in all of your users' shell rc files if you want to keep all user-invoked Java applications safe.

Good reference: Difference between _JAVA_OPTIONS, JAVA_TOOL_OPTIONS and JAVA_OPTS

If you are talking about server configurations, you must consult each server configuration files, or maybe there would be ways to set such command line options to your server instances. Check your server product name and retry searching.

MNEMO
  • 268
  • 2
  • 11