Set JAVA_OPTS in JBOSS standalone.sh file
Asked Answered
C

2

6

I have an app on jboss which logging through log4j. When I running my server through bat file (standalone.bat) logs work, but there is a problem under standalone.sh file. Here is how I set JAVA_OPTS in standalone.bat:

set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j.configuration=file:../standalone/configuration/log4j.xml"

and it works. How should I do this in standalone.sh file? I tried something like this:

JAVA_OPTS= "$JAVA_OPTS -Dlog4j.configuration=file:$JBOSS_HOME/standalone/configuration/log4j.xml"

But it doesn't work. Any ideas? Thanks in advance for your help.

Calise answered 23/9, 2013 at 11:7 Comment(1)
Have you tried using standalone.conf instead of *.sh? Add your custom entries at the end of *.conf file. Something like JAVA_OPTS= "$JAVA_OPTS -Dlog4j.configuration=file:../standalone/configuration/log4j.xml" should work fine.Maddock
O
4

The standalone.sh file will be interpreted by the shell, so it needs to be valid shell script. Remove the space after the = and you should be good. That makes the java opts line look like:

JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$JBOSS_HOME/standalone/configuration/log4j.xml"
Obviate answered 15/4, 2014 at 17:17 Comment(0)
D
3

Adding a JAVA_OPTS= line to standalone.conf (as Pawel mentioned) seems to work great. Then run standalone.sh as usual. You should see your JAVA_OPTS listed in the boot-up message.

Darleen answered 16/12, 2014 at 18:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.