问题
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:
- Go to
[server folder]\bin
- Edit
run.bat
(if server is running on Windows) orrun.sh
(for Linux) - 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
来源:https://stackoverflow.com/questions/11040936/how-do-you-specify-an-external-log4j-properties-file-to-start-a-jboss-server