0
votes

I'm working with weblogic 12c and jdk 1.8. At the start of my application there is the BeEnvironment class that loads the internal log4j.properties in this mode:

    if (Thread.currentThread().getContextClassLoader().getResourceAsStream(CONFIGURATION + File.separator + mwaEnv + File.separator + Constants.LOG_4_j) != null) { 
        System.out.println("CARICO LE IMPOSTAZIONI DI LOG4J DA: " + CONFIGURATION + File.separator + mwaEnv + File.separator + Constants.LOG_4_j);
        PropertyConfigurator.configure(this.getClass().getClassLoader().getResource(CONFIGURATION + File.separator + mwaEnv + File.separator + Constants.LOG_4_j));
    }       

The string "CONFIGURATION + File.separator + mwaEnv + File.separator + Constants.LOG_4_j" is the path where the file log4j.properties is located. This path is under the classpath (src/main/resources) of the project.

The problem is that weblogic does not find the file log4j.properties. The same code in webphere application server goes well. Maybe I have to configure some tag in weblogic.xml?

1
the file is under WEB-INF\classes or WEB-INF ?devwebcl
You should add -Dlog4j.debug to your setDomainEnv.cmd (i.e. add it to EXTRA_JAVA_PROPERTIES) and that should give you some extra information as to what is happening with LOG4J..mkane
The log4j.properties file is under this path (WEB-INF\classes) C:\repo_git\gestoreposizioni-ubi\GestorePosizioni-ear\target\GestorePosizioni.ear\GestorePosizioni.war\WEB-INF\classes\configuration\SVI\log4j.propertiesuser3310573
When I deploy the ear on weblogic testing environment the application find the log4j.properties file whereas in my weblogic local environment the application does not find the log4j.properties. I think that the installation of my weblogic local environment is not good. The problem does not depend on java codeuser3310573
In my weblogic local environment I have the same problem, properties file not found, with the environment.properties files. But I succedded in resolving it with this java code: properties = (PropertyResourceBundle) ResourceBundle.getBundle (CONFIGURATION_PROPERTIES + mwaEnv + FILE_PROPERTIES); I also succedded in reading log4j.properties file putting it under the root of my project and using this java code: PropertyConfigurator.configure("conf/SVI/log4j.properties"); Thanksuser3310573

1 Answers

0
votes

I substitute File.Separator with "/" to get the right path of properties files. In this way all goes well. I think the problem is that weblogic is installed on Windows. File.separator is "\" in windows-like mode. Whereas Weblogic wants "/" to get properties files from classpath.