Quantcast
Channel: Pentaho Community Forums - BI Platform
Viewing all articles
Browse latest Browse all 2893

Log rotation for Pentaho 5.3 BI server

$
0
0
Hi -

I wanted to share our experience in setting up proper log rotation. As it is out of the box, Pentaho doesn't seem to do much log rotation - Catalina.out grows endlessly, and many other logs while they rotate they don't stop adding new ones.

To fix this, we made the following changes:

1) Create a file called tomcat, which you will place in /etc/logrotate.d/ on linux.
Code:

# logrotate config file to rotate out the catalina.out for Tomcat file,
# which will grow too large otherwise. This rotates daily, compressing
# the result, and keeping 7 days worth of logs.
/var/www/biserver-ce/tomcat/logs/catalina.out {
    daily
    copytruncate
    missingok
    rotate 7 
    dateext
    compress
      delaycompress
    notifempty
}

2) Change tomcat/conf/logging.properties to the following, which uses java.util.logging.FileHandler, keeps last 5 files, and keeps up to 20mb in each file. Also changing level to warning drastically reduces the size of these logs.
Code:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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

.handlers = 1catalina.java.util.logging.FileHandler, java.util.logging.ConsoleHandler
 
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

# Store ~20MB of logs at a time, keep last 5 around
1catalina.java.util.logging.FileHandler.level = WARNING
1catalina.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/catalina.%g.log
1catalina.java.util.logging.FileHandler.limit = 20971520
1catalina.java.util.logging.FileHandler.count = 5
1catalina.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

2localhost.java.util.logging.FileHandler.level = WARNING
2localhost.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/localhost.%g.log
2localhost.java.util.logging.FileHandler.limit = 20971520
2localhost.java.util.logging.FileHandler.count = 5
2localhost.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

3manager.java.util.logging.FileHandler.level = WARNING
3manager.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/manager.%g.log
3manager.java.util.logging.FileHandler.limit = 20971520
3manager.java.util.logging.FileHandler.count = 5
3manager.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

4host-manager.java.util.logging.FileHandler.level = WARNING
4host-manager.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/host-manager.%g.log
4host-manager.java.util.logging.FileHandler.limit = 20971520
4host-manager.java.util.logging.FileHandler.count = 5
4host-manager.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

java.util.logging.ConsoleHandler.level = WARNING
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = WARNING
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.java.util.logging.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = WARNING
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.java.util.logging.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = WARNING
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.java.util.logging.FileHandler

3) Change the pentaho.log settings in log4j.xml, found in tomcat/webapps/pentaho/WEB-INF/classes, as follows, which keeps 5 files around of 20mb in size. I think you need to download the apache log4j extras file to make this work and drop in the jar directory.
Code:

<appender name="PENTAHOFILE" class="org.apache.log4j.rolling.RollingFileAppender">
      <param name="File" value="../logs/pentaho.log" />
      <param name="Append" value="true" />
      <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
        <param name="FileNamePattern" value="../logs/pentaho.%i.log" />
        <param name="ActiveFileName" value="../logs/pentaho.log" />
        <param name="MaxIndex" value="5" />
      </rollingPolicy>
      <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
        <param name="MaxFileSize" value="20971520" />
      </triggeringPolicy>     
      <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
      </layout>
  </appender>

Hope this helps someone, and I welcome any suggestions for improvement to the above. You can also disable audit logging if you don't need it.

Viewing all articles
Browse latest Browse all 2893

Trending Articles