【发布时间】:2013-04-16 20:21:13
【问题描述】:
我用 Spring 设置了一个 JAX-WS,除了 log4j 之外一切正常:
我正在关注官方的 sping 文档: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export-servlet
其中 Endpoint 定义如下:
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
@WebService(serviceName="AccountService")
public class AccountServiceEndpoint extends SpringBeanAutowiringSupport {
@Autowired
private AccountService biz;
@WebMethod
public void insertAccount(Account acc) {
biz.insertAccount(acc);
}
然后我尝试在 AccountService 的 impl 中写入日志:
public class AccountServiceImpl implements AccountService {
private static Logger logger = Logger.getLogger(AccountServiceImpl.class.getName());
...
public void insertAccount(Account acc) {
logger.debug("someting... " )
....
}
}
在 web.xml 中
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:my_log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
我已经测试了 my_log4j.xml,配置是绝对正确的,而且我在启动时也得到了显示 my_log4j.xml 在 WebApplicationContext 初始化之前加载的日志
我想知道是不是因为 WebService 用完了 Spring 那么 log4jConfigLocation 不起作用
我使用的服务器是 Websphere Application Server 7.0
【问题讨论】:
-
您的某个依赖项是否将 Log4j 作为依赖项?
-
是的,当然,我可以在 WEB-INF/lib 文件夹中看到 log4j jar
-
这不是我问的。您的项目中是否还有其他也使用 log4j 的依赖项?
-
哦,对不起,对于你的问题,我认为不,因为这个应用程序在没有 log4j 之前可以很好地退出
-
这并不意味着什么。我们通常在一些内部log4j配置与项目的log4j配置冲突时会出现这个问题
标签: java web-services log4j websphere jax-ws