gpt4 book ai didi

java - log4j 在带有 Spring 的 JAX-WS 中无法正常工作

转载 作者:行者123 更新时间:2023-11-30 11:33:15 25 4
gpt4 key购买 nike

我用 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

端点定义如下:

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 的实现中写入日志:

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

最佳答案

最终通过将类加载器策略更改为 PARENT_LAST 来解决问题,问题已关闭

关于java - log4j 在带有 Spring 的 JAX-WS 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16172405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com