Gemfire Log File not Rolling at log-file-size-limit
search cancel

Gemfire Log File not Rolling at log-file-size-limit

book

Article ID: 294294

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Symptoms:

This article describes how to resolve a situation where the GemFire log file is not rolling at the log-file-size-limit.

The size of the GemFire log file may grow (potentially, much) larger than the "log-file-size-limit" as its set in gemfire.properties.

Environment


Cause

GemFire tracks log file size by tracking the size of log messages as they are logged. Hence, the mechanism by which GemFire checks log file size against the "log-file-size-limit" will not include logging which is captured from stdout or stderr rather than going through the usual logging API. In other words, logging to stdout or stderr that is redirected into the GemFire log bypasses the usual file size monitoring, so will not be considered in the size of the log file for the purpose of log rolling.


For example, if you use System.out.println() to output logs into the GemFire log from a cacheListener, those logs will not be counted in the log-file-size-limit check.

Resolution

In order to resolve this, there are two possible options:

  1. Use GemFire's internal logger API to pipe application logging into the GemFire log file.

    Example:

    GemFireCacheImpl.getInstance().getLogger().info("application log");
    
  2. Use log4J/log4J2 to pipe application logging into a separate application log rather than the GemFire log file.

    For example (log4J):

    log4j.rootLogger=info, R
    
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=/home/gemfire/server/gfapp.log
    log4j.appender.R.MaxFileSize=1MB
    
    log4j.appender.R.MaxBackupIndex=10
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=[%-5p] %d [%c{1}] [%t]- %m%n