how to set log4j.configuration system variable in WebSphere 7?

后端 未结 3 1488
囚心锁ツ
囚心锁ツ 2020-12-31 17:13

I have a Java EE 5 web app I\'m deploying to WebSphere 7 as an EAR file.

I want my log4j configuration to be external to the EAR file so I can tweak log content when

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-31 17:54

    I find a solution to assign to each EAR or WAR an external log4j.xml configuration file:

    1. I extracted the log4j.xml from our EAR, Zipped this lone XML into a JAR file. Placed it on the server in a path accessible by WebSphere,
    2. Create a Shared Library (WebSphere > Environment > Shared Libraries) mapping the classpath to this archive. Make sure to select "Use an isolated class loader for this shared library" or you'd have to assign reference for each module of your application rather than just the parent EAR.
    3. Assigning the reference within our EAR (Application -> ApplicationType -> WebSphere enterprise applications -> EAR NAME -> Shared library references -> SELECT YOUR EAR -> Reference shared libraries -> SELECT THE LOG4J CONFIGURATION JAR) and ADD IT.
    4. Restart the application

    I used this way to assign a specific external log4j configuration file to each WAR in an an EAR. Here you can find the original solution.

提交回复
热议问题