2017-02-09 111 views
0

爲我的Glassfish 4.1.1我配置路徑屬性的應用程序文件中web.xml無法加載屬性的log4j 2從路徑磁盤文件

<context-param> 
     <param-name>log4jConfiguration</param-name> 
     <param-value>file:///G:/log4j2.properties</param-value> 
</context-param> 

我的屬性文件:

name=LoggingProperties 
property.filename = logs 
appenders = console, file 

appender.console.type = Console 
appender.console.name = STDOUT 
appender.console.layout.type = PatternLayout 
appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n 

appender.file.type = File 
appender.file.name = LOGFILE 
appender.file.fileName=${filename}/propertieslogs.log 
appender.file.layout.type=PatternLayout 
appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n 

loggers=file 
logger.file.name=com.ax 
logger.file.level = debug 
logger.file.appenderRefs = file 
logger.file.appenderRef.file.ref = LOGFILE 

rootLogger.level = debug 
rootLogger.appenderRefs = stdout 
rootLogger.appenderRef.stdout.ref = STDOUT 

每當我將把我的文件,它總是顯示:ERROR StatusLogger No log4j2 configuration file found. Using default configuration

回答

0

您的配置看起來正確的,但請務必在log4j-web-2.x.jar模塊添加到您的classpa日。 (這包含從web.xml讀取配置位置的邏輯。)

+0

我已經在maven pom文件中添加了它,並且還添加了核心和api模塊。 –

+0

當文件位於EJB資源文件夾中時,會加載屬性。不幸的是,我需要從EAR文件外部訪問該文件。 –

相關問題