WEBLOGIC单机集群log4j的设置
1.log4j代码片段(log4j的配置文件支持System Property的环境变量的获取)
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="D:/${weblogic.Name}ank.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd-HH" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} %m%n" />
</layout>
</appender>
2.${weblogic.Name}对应的是JAVA启动时环境变量;
看startWebLogic.sh中的代码片段
D:\bea92\JDK150~1\bin\java -client -Dweblogic.Name=AdminServer
如何设置JAVA启动时的环境变量:
java -D<参数>=<值>
3.使用spring中的Log4jConfigListener把log文件定在 /WEB-INF/logs/ 而不需要写绝对路径。
log4j.xml配置片段:
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="${webapp.root}/WEB-INF/logs/${weblogic.Name}-jrwwg.log" /> <param name="DatePattern" value="'.'yyyy-MM-dd-HH" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %c{1} %m%n" /> </layout> </appender>
web.xml配置片段
<context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log/log4j.xml</param-value> </context-param> <!---定时扫描loj4j配置文件的变化---->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>6000</param-value>
</context-param>
<listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>
相关推荐
chw0 2020-11-04
sdaq 2020-07-26
MrLiar 2020-07-07
sdaq 2020-06-16
丨Fanny丨Cri 2020-06-13
CXC0 2020-06-08
MrLiar 2020-06-04
丨Fanny丨Cri 2020-06-03
丨Fanny丨Cri 2020-05-17
JavaWinner 2020-05-10
JavaWinner 2020-05-04
CXC0 2020-04-20
CXC0 2020-04-10
丨Fanny丨Cri 2020-02-18
MrLiar 2020-02-16
CXC0 2020-02-09