Search code examples
javaweb-serviceslog4jwebspherejax-ws

log4j not working correctly in JAX-WS with Spring


I setup a JAX-WS with Spring , everthing works except the log4j :

I am following The offical sping document : http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export-servlet

which with Endpoint defined like this:

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);
}

then I tried to write log in the impl of AccountService :

public class AccountServiceImpl implements AccountService {
    private static Logger logger =   Logger.getLogger(AccountServiceImpl.class.getName()); 
     ... 
     public void insertAccount(Account acc) {
         logger.debug("someting... " ) 
         ....
     }   
 }

and in 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> 

I have tested my_log4j.xml, the configuration is absolute correct, and I also got log at startup that shows my_log4j.xml was loaded before the WebApplicationContext init

I am wondering if it is bescause the WebService is runing out of Spring then the log4jConfigLocation is not working

The server I am using is Websphere Application Server 7.0


Solution

  • finally fixed by changing the class loader policy to PARENT_LAST, question closed