我已使用MethodInvokingFactoryBean为log4j初始化程序配置了应用程序上下文
在log4j-cert.xml中,我需要获取环境变量“ LOG_LEVEL_VAL”并将其传递到日志级别。但这不起作用。
下面是我的log4j-cert.xml
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="File"
value="/appl/apache-tomcat/logs/DCM-CORE-New_Cost_Scanner_info_${sys:LOG_LEVEL_VAL}.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="500MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p (%c %M:%L) %x - %m%n" />
</layout>
</appender>
<appender name="admin" class="org.apache.log4j.RollingFileAppender">
<param name="File"
value="/appl/apache-tomcat/logs/DCM-CORE-New_Cost_Scanner_error.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="1024MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p (%c %M:%L) %x - %m%n" />
</layout>
</appender>
<logger name="ERRORLOG">
<level value="ERROR" />
<appender-ref ref="admin" />
</logger>
<logger name="INFOLOG">
<level value="INFO" />
<appender-ref ref="file" />
</logger>
<root>
<level value="INFO" />
</root>