在将spring应用程序部署到websphere时,我面临一个日志记录问题。我将spring 4.1.6用于以下依赖项:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
对于日志记录,我使用以下方法:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
在我的web.xml中,我已配置为从外部*.properties文件读取log4j配置:
<!-- context params -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>file:${APP_CFG}/test-api/log4j.properties</param-value>
</context-param>
<!-- listeners -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
在这里,我向websphere“app\u cfg”添加了一个环境变量,以指向存储log4j.properties文件的目录。
log4j.properties的内容如下:
log4j.rootLogger=DEBUG, stdout, logfile
log4j.logger.com.test=DEBUG, stdout, logfile
log4j.additivity.com.test=false
log4j.logger.org.springframework=DEBUG, logfile
log4j.additivity.org.springframework=false
log4j.logger.org.springframework.security=DEBUG, logfile
log4j.additivity.springframework.security =false
log4j.logger.org.springframework.jdbc.core.StatementCreatorUtils=TRACE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=D:/var/log/app/test-app/test-app.log
log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
当服务器启动时,会创建日志文件,但是不会向其写入任何内容,它始终保持为空,因为知道在其他环境(tomcat、jboss等)中,同一应用程序的日志记录正在正常进行,并且会按预期填充日志文件。
请告知可能导致问题的原因。可能缺少特定于websphere的配置?
提前谢谢,问候,
暂无答案!
目前还没有任何答案,快来回答吧!