0

I am working on one of the project. We are deploying that project in weblogic 12.1.3. In that project, client want log4j.properties file outside from the EAR/WAR file. I try to configure as below in web.xml:-

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>
        file://C:/externalProperties/ODCMsgProcessing/log4j/log4j.properties
    </param-value>
</context-param>

But It is giving me exception when I am trying to deploy it on weblogic as:-

<Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.util.Log4jConfigListener failed: java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded.
java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded
    at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:155)
    at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:119)
    at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:49)
    at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:678)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    Truncated. see log file for complete stacktrace
> 

If I deploy project in folder format, than, it is deploying successfully. But I want to deploy it in WAR or EAR format only. So can anybody suggest me any alternate solution where I can configure log4j.properties file outside EAR/WAR.

  • This works for me in the same scenario as yours. https://stackoverflow.com/questions/2594689/external-log4j-xml-file – Jan B. Nov 23 '17 at 08:09
  • This is working for me also If I deploy project without EAR or WAR. But when I am creating WAR or EAR and then if I try to deploy, In that case I am getting above exception. – Sushant Bhoite Nov 23 '17 at 08:56
  • set env with `-Dlog4j.configuration=/path/to/log4j.properties` as in above linked answer – Chacko Nov 23 '17 at 09:04
  • I am working with web application. So with that I think, suggested solution will not work. – Sushant Bhoite Nov 24 '17 at 08:21

0 Answers0