问题描述
我需要这样的东西:
" param name =" file" value =" $ {catalina_home}/logs/log4j.log"
我看到了很多类似的问题,但是没有工作解决方案.
推荐答案
您可以执行以下操作:
- 使用-D选项将CATALINA_HOME作为环境变量发送.您只需要运行
set JAVA_OPTS=%JAVA_OPTS% -DCATALINA_HOME=%CATALINA_HOME%如果您在Windows上或 export JAVA_OPTS=${JAVA_OPTS} -DCATALINA_HOME=$CATALINA_HOME对于unix.
现在只使用$ {catalina_home}到您的log4j配置文件中,这应该有效.
其他推荐答案
用于tomcat 6.0或较新的使用catalina.base(而不是catalina.home):
param name="File" value="${catalina.base}/logs/log4j.log"
根据主机系统,两个可能不同,例如:
catalina.home: /usr/share/tomcat7 catalina.base: /var/lib/tomcat7
catalina.home有bin文件夹.
在catalina.base下有logs,logs,webapps和其他文件夹/链接.
tomcat使用catalina.base本身来配置记录目录 - 请参见conf/logging.properties在哪里说:
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
其他推荐答案
param name="File" value="${catalina.home}/logs/log4j.log"
catalina.home属性已经由tomcat提供.
在 tomcat 5.5登录页面上,找到一个(非常)简短的示例以及以下问题中的其他细节:
问题描述
I need something like this:
"param name="File" value="${CATALINA_HOME}/logs/log4j.log"
I saw a lot of similar questions, but there is no working solutions.
推荐答案
You can do the following:
- send the CATALINA_HOME as an environment variable using -D option. You just have to run
set JAVA_OPTS=%JAVA_OPTS% -DCATALINA_HOME=%CATALINA_HOME% if you are on windows or export JAVA_OPTS=${JAVA_OPTS} -DCATALINA_HOME=$CATALINA_HOME for unix.
Now just use ${CATALINA_HOME} into your log4j configuration file and this should work.
其他推荐答案
For Tomcat 6.0 or newer use catalina.base (rather than catalina.home):
param name="File" value="${catalina.base}/logs/log4j.log"
Depending on the host system, the two may be different, for example:
catalina.home: /usr/share/tomcat7 catalina.base: /var/lib/tomcat7
Under catalina.home there's the bin folder.
Under catalina.base there are conf, logs, webapps and other folders/links.
Tomcat uses catalina.base itself to configure the logging directory - see conf/logging.properties where it says:
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
其他推荐答案
param name="File" value="${catalina.home}/logs/log4j.log"
The catalina.home property is already made available by Tomcat.
Find a (very) brief example on the Tomcat 5.5 logging page and additional detail in the following SO question: