Pivotal Knowledge Base

Follow

Gemfire log file not rolling at log-file-size-limit

Environment

Product Version
Pivotal GemFire 7.x - 8.x

Overview

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

Symptom

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

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.

    For 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
    

     

Additional Information

For further information, please refer to the following resources:

  • For the GemFire internal logger API usage, you can refer the example under [Gemfire_Installation_Home]/SampleCode/examples/dist/cacheRunner/LoggingCacheCallback.java
  • Beginning with GemFire 8.1+, GemFire uses Log4J2 for logging and no longer pipes stdout/stderr to a file. Applications should use a logging API such as Log4J2.

 

Comments

Powered by Zendesk