从 weblogic 域目录读取配置文件
我有一个配置文件,其中列出了 Logback.xml 的所有配置详细信息,例如日志文件位置和日志级别等。我将此文件放置在 weblogic 域目录下的资源中。我的项目中还有一个属性文件,它应该指向配置文件。像这样的东西。
iam.config.file=resources/iam_config.properties
我的 logback.xml 看起来像这样
<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>
所以我的想法是我更改日志配置而无需重新部署。但我无法让它工作,因为部署项目时 weblogic 无法找到该文件。我如何更改
iam.config.file=resources/iam_config.properties
以正确指向该文件。谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用通用文件覆盖功能来打包应用程序外部的属性
http://download.oracle.com/docs/cd/E21764_01/web.1111/e13702/config.htm#i1066493
使用应用程序安装目录打包应用程序时
http://download.oracle.com/docs/cd/E21764_01/web.1111/e13702/deployunits.htm#i1047223
请注意,这需要您使用以下命令查找属性ContextClassLoader,如果您希望在不重新部署的情况下读取文件,您可能必须在部署期间使用无阶段或外部阶段模式,而不是上演:
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: