How do you specify an external log4j properties fi

2019-07-29 09:30发布

问题:

How do you specify an external log4j properties file to run a jboss server with?

I need to do this with bash/ terminal commands? Not programmatically

回答1:

Create a folder to store log4j.properties (i.e C:\PropertiesFolder).
Then add the link to this folder to JBoss classpath:

  1. Go to [server folder]\bin
  2. Edit run.bat (if server is running on Windows) or run.sh (for Linux)
  3. Edit classpath line by adding the folder link:

Snippet:

if "x%JBOSS_CLASSPATH%" == "x" (
  set "RUN_CLASSPATH=%RUNJAR%;C:\PropertiesFolder;"
) else (
  set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%;C:\PropertiesFolder;"
)

Finally restart the server then run by command line (go to [server folder]\bin then type run)



回答2:

You can put the log4j.properties file in the classpath.



回答3:

If the target version of Jboss is 7.1.x - then you need to follow the simple 2 steps, that are described in the official documentation.

How do I use log4j.properties or log4j.xml instead of using the logging subsystem configuration?

https://docs.jboss.org/author/display/AS71/How+To#HowTo-HowdoIuselog4j.propertiesorlog4j.xmlinsteadofusingtheloggingsubsystemconfiguration%3F

Hope that helps



标签: java jboss log4j