Friday, December 7, 2012

Store Alfresco n Tomcat logs in one dir

How to store all log files of Alfresco & Tomcat under common directory on Ubuntu?

We know that log files of Tomcat (catalina.out, localhost.log) are stored under /var/lib/tomcat6/logs directory and for Alfresco, its alfresco.log file stored under /var/lib/tomcat6 directory. We will store all logs under /var/log/tomcat6 directory.

1) Stop tomcat.
/var$ sudo /etc/init.d/tomcat6 stop

2) We can override properties in /var/lib/tomcat6/webapps/alfresco/WEBINF/classes/log4j.properties file by coping log4j.properties file to /var/lib/tomcat6/shared/classes/alfresco/extension/custom-log4j.properties file.

/var$ sudo cp /var/lib/tomcat6/webapps/alfresco/WEBINF/classes/log4j.properties

/var/lib/tomcat6/shared/classes/alfresco/extension/customlog4j.properties

Set log4j.appender.File.File=/var/log/tomcat6/alfresco.log in custom-log4j.properties file.

###### File Appender Definition #######
log4j.appender.File=org.apache.log4j.DailyRollingFileAppender
log4j.appender.File.File=/var/log/tomcat6/alfresco.log
log4j.appender.File.Append=true
log4j.appender.File.DatePattern='.'yyyy-MM-dd
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n

Change the ownership to tomcat6 for user & group.
/var$ sudo chown tomcat6:tomcat6 /var/lib/tomcat6/shared/classes/alfresco/extension/customlog4j.properties

3) Edit the path for catalina.out & localhost.log in /var/lib/tomcat6/conf/logging.properties file.

1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory =/var/log/tomcat6
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = /var/log/tomcat6
2localhost.org.apache.juli.FileHandler.prefix = localhost.

Change the ownership to tomcat6 for user & group.
/var$ sudo chown tomcat6:tomcat6 /var/lib/tomcat6/conf/logging.properties

4) Start tomcat.
/var$ sudo /etc/init.d/tomcat6 start

5) Check the log files created under /var/log/tomcat6/ directory.
/var$ tail -100f /var/log/tomcat6/catalina.out
/var$ tail -100f /var/log/tomcat6/alfresco.log

NOTE:
1) Logs related to Alfresco Web App will get stored in /var/log/tomcat6/alfresco.log file.

2) Logs related to Share Web App (If Share application is installed on same tomcat) will get stored in /var/lib/tomcat6/alfresco.log file.

3) If you want to store Share Application logs under same directory i.e. /var/log/tomcat6/ as
share.log file then, you need to edit the default file /var/lib/tomcat6/webapps/share/WEBINF/
classes/log4j.properties as there is no extension mechanism for Share App log4j.properties entries.

Edit /var/lib/tomcat6/webapps/share/WEB-INF/classes/log4j.properties file.

log4j.appender.File.File=/var/log/tomcat6/share.log

From Alfresco v4.2.a CE onwards, by default all logs for Share Application goes in a separate /var/lib/tomcat6/share.log file and for Alfresco, it goes in /var/lib/tomcat6/alfresco.log file.



In Association with Amazon.in

No comments:

Post a Comment