Simple tips about Alfresco logs

Basic maintenaince of your Alfresco logs

Today I put together some basic tips about Alfresco logs in Alfresco installations.

1. Rotate catalina.out

The Tomcat Server log file catalina.out grows and grows by default. You can use a custom log4j.properties for default Tomcat configuration, but you can easier use logrotate for catalina.out 

$ sudo vim /etc/logrotate.d/alfresco

/opt/alfresco/tomcat/logs/catalina.out {
  copytruncate
  daily
  rotate 10
  missingok
  dateext
  size 50M
}


If logrotate is not used by the operating system you can define a cronjob with crontab -e for your Alfresco user (owner of java process) with:

#IMPORTANT: As Alfresco user
$ crontab -e 

0 5 * * 1 /usr/sbin/logrotate /etc/logrotate.d/alfresco

 

2. Logs always under $TOMCAT/logs directory

It is very usual to see Alfresco logs in different folders, between $ALF_HOME, and $ALF_HOME/tomcat/logs when installing with the Alfresco bundle. You can change your log4j.properties for alfresco.war, share.war, or solr4.war applications (and manager and host-manager too) but the next tip is easier for keeping together in the same place. This is valid for recent Alfresco 4 and 5:

 1. Change $ALF_DATA/alfresco.sh script adding the next line under INSTALLDIR variable:

cd $INSTALLDIR/tomcat/logs


 2. Comment in $ALF_DATA/tomcat/scripts/ctl.sh the "cd" lines:

#cd $CATALINA_HOME/..
.
.
.

#cd $previousdir

 

3. Clean logs periodically

You can use a simple crontab script for deleting old rotated logs.

#!/bin/bash
# Crontab for your Alfresco user (owner of java process)
# 0 5 * * 1 /opt/alfresco/bin/clean-logs.sh

ALF_HOME=/opt/alfresco

LOGS_TOM=$ALF_HOME/tomcat/logs
LOGS_DAYS=30

find ${LOGS_TOM}/* -mtime +${LOGS_DAYS} -name \*.log\* -delete 2>/dev/null



4. Disable Tomcat localhost logs (localhost_access_log*)

Sometimes it is desired to disable localhost_access_log* logs. For this, you should comment the valve part in server.xml config

$ vim $ALF_HOME/tomcat/conf/server.xml

<!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
-->


(and restart Alfresco Service)


5. Disable manager and host-manager logs

It is usual to disable manager and host-manager under webapps in production environment. For their preconfigured log files edit $ALF_HOME/tomcat/conf/logging.properties using only:

handlers = 1catalina.java.util.logging.FileHandler

and comment all related lines regarding:

  • 2localhost.java.util.logging.FileHandler
  • 3manager.java.util.logging.FileHandler
  • 4host-manager.java.util.logging.FileHandler

External links and helping sources:

00

More Blog Entries

thumbnail
thumbnail

3 Comments

AB
Angel borroy 4 Years Ago

Alternative for point 2 in Alfresco 6 (Docker Compose) available at

https://github.com/keensoft/docker-alfresco/blob/master/alfresco/Dockerfile#L10

10
AS
Ainsof So'o 4 Years Ago

I am using Alfresco Community 5.2 and in step 5 my handlers are listed as:

 

handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

 

instead of

 

handlers = 1catalina.java.util.logging.FileHandler

 

as suggested I put

 

handlers = 1catalina.org.apache.juli.FileHandler

 

instead.

 

Is this correct?

00
Cesar Capillas 4 Years Ago

Hi:

 

The handler used in an Alfresco 5 clean install is catalina.java.util.logging.FileHandler with Tomcat 7. I think the handler that you mentioned is used in Tomcat 8. If this is the case, you are correct. The important part is to exclude annoying logs for manager, and host manager apps. 

 

Kind regards.

--C.

00