Reputation: 121
I am running tomcat7 on ubuntu 14.04. I need to change the folder location for the log file: /var/log/tomcat7/catalina.out
I tried the following:
Set environment variable CATALINA_OUT in the /etc/environment file to my custom location: CATALINA_OUT=/xyz/catalina.out
In the /etc/tomcat7/logging.properties, i updated the below property: 1catalina.org.apache.juli.FileHandler.directory = /xyz (this starting saving catalina.2016-03-19.log files to my custom location; instead of the catalina.out)
Neither of the above work for me. Please help. Thanks Jaskaran
Upvotes: 4
Views: 22328
Reputation: 12797
You can follow below to change Tomcat
Log Locations as you prefer:
This is for Linux: and should be mostly the same for Windows as well.
Locate the tomcat installed location: <tomcat-base>/conf/logging.properties
catalina.org.apache.juli.AsyncFileHandler.level = FINE
catalina.org.apache.juli.AsyncFileHandler.directory = <add_location_you_prefer>
catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
localhost.org.apache.juli.AsyncFileHandler.level = FINE
localhost.org.apache.juli.AsyncFileHandler.directory = <add_location_you_prefer>
localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
manager.org.apache.juli.AsyncFileHandler.level = FINE
manager.org.apache.juli.AsyncFileHandler.directory = <add_location_you_prefer>
manager.org.apache.juli.AsyncFileHandler.prefix = manager.
host-manager.org.apache.juli.AsyncFileHandler.level = FINE
host-manager.org.apache.juli.AsyncFileHandler.directory = <add_location_you_prefer>
host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
Finally you will need to change the catalina.out
:
Locate the following code snippet in Catalina.sh
script in bin directory of your tomcat base location:
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
Change the
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
to:
CATALINA_OUT=<add_location_you_prefer>/catalina.out
Upvotes: 0
Reputation: 11
Method 1.) For example to write log files in "D:/logs" path, edit /tomcat7/config/logging.properties as like shown below and restart the tomcat service.
1catalina.org.apache.juli.FileHandler.directory = D:/logs
2localhost.org.apache.juli.FileHandler.directory = D:/logs
3manager.org.apache.juli.FileHandler.directory = D:/logs
4host-manager.org.apache.juli.FileHandler.directory = D:/logs
Note: It only write log files like catalina, manager, host-manager, commons-deamon.
If you want to write stdout and stderr file also in the same path, follow second method.
Method 2). Go to /tomcat7/bin/ and open Tomcatw.exe with administrator rights -> Logging tab -> At Log path specify D:\logs. Apply settings and restart the tomcat service.
Note: Before applying the changes kindly check READ/WRITE permission given to appropriate user that the tomcat used (Log On) to run it's service.
Upvotes: 1
Reputation: 4900
I have the same problem with tomcat 8.5.*
I followed the advice from rod.poli.diniz and did the following:
Created an environment variable in my ~/bash_profile
export CATALINA_LOGS_1=/home/user1/apps/logs/app1
In tomcat <tomcat-base>/bin/setenv.sh
added the following JVM argument that is identified in <tomcat-base>/conf/logging.properties
.
-Dcatalina.logs=$CATALINA_LOGS_1
Then updated <tomcat-base>/conf/logging.properties
.
1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.logs}/catalina
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.logs}/catalina
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.logs}/catalina
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.logs}/catalina
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
In <tomcat-base>/logs/
:
catalina.out
localhost_access_log.2019-04-12.txt
tomcat.pid
In $CATALINA_LOGS_1
:
catalina.2019-04-12.log
host-manager.2019-04-12.log
localhost.2019-04-12.log
manager.2019-04-12.log
In <tomcat-base>/logs/
:
tomcat.pid
In $CATALINA_LOGS_1
:
catalina.out
localhost_access_log.2019-04-12.txt
catalina.2019-04-12.log
host-manager.2019-04-12.log
localhost.2019-04-12.log
manager.2019-04-12.log
Update <tomcat-base>/bin/setenv.sh
with the following:
mkdir -p $CATALINA_LOGS_1
CATALINA_OUT=$CATALINA_LOGS_1/catalina.out
Update <tomcat-base>/conf/server.xml
find the AccessLogValve. Replace directory="logs"
: --> directory="${cfrm.logs}"
Upvotes: 4
Reputation: 1483
The default place for tomcat logging configuration is:
CATALINA_HOME/conf/logging.properties.
You need to edit this file if you want to change the logging location. For tomcat 7 you have like this inside the file:
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
You need to replace ${catalina.base}/logs to your desired new directory/path. That is for tomcat's core logging. For your web application you should do that inside your specific application's log4j or other logging framework.
Upvotes: 1