Pivotal Knowledge Base

Follow

How to Configure GemFire Pulse Logging in Embedded Mode

Environment

Pivotal GemFire 8.X and 9.X.

Purpose

The purpose of this article is to explain some details about how GemFire Pulse logging can be configured when Pulse is running in an embedded mode, both for versions 8.X and 9.X.

The approach used for both versions differs, primarily because GemFire started extensively using Apache log4j as the underlying logging framework on version 9.X.

Procedure

GemFire 8.2.X

This is an easy approach as the logging configuration is directly controlled by the system properties set when starting the locator process. Below is the summary of the available properties that can be used along with a brief description of each one:

  • pulse.Log-Level- It is the log-level to use. It can be set as "OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL".
  • pulse.Log-Append- It specifies append mode. If set to "true", new logs will be added to the current existing file and if set to "false", a new log file will be created every time.
  • pulse.Log-File-Size0- It represents the maximum number of bytes to write to any one file. This is internally represented as a simple "int", so the maximum value is "Integer.MAX_VALUE = 2e31-1".
  • pulse.Log-File-Count- It is the maximum number of files to use.
  • pulse.Log-File-Name- It is the file name that will be used.
  • pulse.Log-File-Location- It is the folder where all the log files will be written.

As an example, assuming that the requirement is for the log files to be named "pulse.log_[fileNumber].log" stored in "/pulseLogs" using the FINEST log-level, have at maximum 5 files, and rotate whenever the individual file size is 10Mb, the following parameters should be added to the locator's startup script:

--J=-Dpulse.Log-File-Name=pulse.log --J=-Dpulse.Log-File-Location=/pulseLogs --J=-Dpulse.Log-Level=FINEST --J=-Dpulse.Log-File-Size=1000000 --J=-Dpulse.Log-File-Count=5

GemFire 9.X.X

This approach needs some knowledge about Apache log4j. The main idea here is to get the default log4j2.xml file shipped with the product, stored in GEMFIRE_HOME/config and make the required modifications to meet the requirements. There are tons of appenders and configurations that can be used but, for the purpose of following the previous example, only RollingFile appender will be shown within this article. The full list of available appenders and the configuration options can be found in Appenders. Keep in mind that only the configuration related to Pulse should be modified. Bad configuration changes to the log4j2.xml file may result in missing statements or information in the logs.

That said, and assuming again that the requirement is for the log files to be named pulse.log_[fileNumber].log, stored in /pulseLogs using the FINEST log-level, have at maximum 5 files and rotate whenever the individual file size is 10Mb, the following parameters should be added to the locator's startup script:

--J=-Dlog4j.configurationFile=/gemfireConfig/log4j2-custom.xml

The contents of /gemfireConfig/log4j2-custom.xml can be found below, the sections marked with <!-- EXTENSION - START/FINISH --> are the ones added to the default GemFire logging configuration.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="FATAL" shutdownHook="disable" packages="org.apache.geode.internal.logging.log4j">
  <Properties>
    <Property name="geode-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} &lt;%thread&gt; tid=%tid] %message%n%throwable%n</Property>
    <Property name="geode-default">true</Property>
  </Properties>
  <Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
      <PatternLayout pattern="${geode-pattern}"/>
    </Console>
<!-- EXTENSION - START -->
    <RollingFile name="PulseRollingFile" fileName="pulse.log_0.log" filePattern="pulse.log_%i.log">
      <PatternLayout>
        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
      </PatternLayout>
      <Policies>
        <SizeBasedTriggeringPolicy size="10 MB"/>
      </Policies>
      <DefaultRolloverStrategy max="5"/>
    </RollingFile>
    <!-- EXTENSION - FINISH -->
</Appenders>
  <Loggers>
    <Logger name="com.gemstone" level="INFO" additivity="true"/>
    <Logger name="org.apache.geode" level="INFO" additivity="true">
      <filters>
        <MarkerFilter marker="GEODE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
      </filters>
    </Logger>
    <Logger name="org.jgroups" level="FATAL" additivity="true"/>
    <Logger name="org.eclipse.jetty" level="FATAL" additivity="true"/>
<!-- EXTENSION - START -->
    <Logger name="org.apache.geode.tools.pulse.internal" level="FINEST" additivity="true">
      <AppenderRef ref="PulseRollingFile"/>
    </Logger>
<!-- EXTENSION - FINISH -->
<Root level="INFO">
      <AppenderRef ref="STDOUT"/>
    </Root>
  </Loggers>
</Configuration>

 

Comments

Powered by Zendesk