Blogs

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:

More Blog Entries

We are speaking at Beecon 2017

Next week we will participate in Alfresco Developer Conference (Beecon 2017), presenting two...

KMeans con Zeppelin y Spark

Siguiendo estos dos artículos de internet, uno donde se explica como crear un modelo...

0 Comments