java中catalina.out_如何在Java程序中检索catalina.out的路径?

我需要获取在logging.properties中配置的catalina.out文件的路径.

有没有一种方法可以通过java检索属性“ 1catalina.org.apache.juli.FileHandler.directory”,而无需知道属性文件的路径?

解决方法:

如果我对您的理解正确,那么您想读取Tomcat logging.properties文件的属性.如您在Tomcat FAQ for Logging中所见,java.util.logging.config.file用于定义属性文件的路径.

String pathLogProps = System.getProperty("java.util.logging.config.file");

Properties properties = new Properties();

try {

properties.load(new FileInputStream(pathLogProps));

System.out.println(prop.getProperty("database"));

} catch (IOException ex) {

ex.printStackTrace();

}

JULI is enabled by default, and supports per classloader

configuration, in addition to the regular global java.util.logging

configuration. This means that logging can be configured at the

following layers:

Globally. That is usually done in the ${catalina.base}/conf/logging.properties file. The file is specified

by the java.util.logging.config.file System property which is set by

the startup scripts.

If it is not readable or is not configured, the default is to use the ${java.home}/lib/logging.properties file in the JRE. In the web

application. The file will be WEB-INF/classes/logging.properties

默认情况下,logging.properties文件的路径应分别在环境变量catalina.base和CATALINA_BASE上可用.

标签:logging,tomcat,tomcat6,java

来源: https://codeday.me/bug/20191201/2077302.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值