2

I have a config file which lists all the configuration details for Logback.xml like the log file location and log level etc. I have this file placed in resources under the weblogic domain dir. I also have a properties file in my project which should be pointing to the config file. Something like this.

iam.config.file=resources/iam_config.properties

and my logback.xml looks like this

 <configuration>
  <property file="${iam.config.file}"/>
  <appender name="iamLogFileAppender" class="ch.qos.logback.core.FileAppender">
    <!-- Tests run on modern PCs show that buffering related property -->
    <!-- "ImmediateFlush" has negligible impact and will be ignored.  -->
    <File>${iam.upm.log.file}</File>
    <Append>false</Append>
    <encoder>
      <pattern>[%d] %-5p %c - %m%n</pattern>
    </encoder>
  </appender>
  <root level="ERROR">
    <appender-ref ref="iamLogFileAppender"/>
  </root>

  <logger name="aero.sita.voyager.iam" level="${iam.upm.log.logLevel}" additivity="false">
    <appender-ref ref="iamLogFileAppender" />
 </logger>
</configuration>

So the idea is I change the log configurations without having to redeploy. But I'm not able to get this working as weblogic is not able to find the file when the project is deployed. How can I change

iam.config.file=resources/iam_config.properties

to correctly point to the file. Thanks.

Ravi
  • 7,939
  • 14
  • 40
  • 43

1 Answers1

1

You can get out the Generic File Overrides feature to package properties outside the application http://download.oracle.com/docs/cd/E21764_01/web.1111/e13702/config.htm#i1066493 when packaging your application with an Application Installation Directory http://download.oracle.com/docs/cd/E21764_01/web.1111/e13702/deployunits.htm#i1047223

Note that this requires you to look up the properties like this with the ContextClassLoader and if you want the file to be read without a redeploy you may have to use no-stage or external stage mode during the deployment instead of staged:

Properties myAppProps = new Properties();
InputStream iostream = Thread.currentThread().getContextClassLoader().getResourceAsStream("myCfg/myApp.properties");
myAppProps.load(iostream);
jambay
  • 316
  • 1
  • 1