Pivotal Knowledge Base


How to filter GemFire logs in 8.0 and later

Applies to

GemFire 8.0 and later


Since GemFire 8.0 the logging in GemFire has been based on Log4J. The purpose of this article is to explain how filtering can now the implemented using Log4J in case certain log entries needs to be suppressed for example to avoid alerts being send for certain error messages.


GemFire uses Log4j to register execution logs, so it is needed to write a custom configuration and make usage of the filters provided by Log4j to avoid the log of a particular message.

The overview of how to implement Log4J custom filters is described in the User's Guide.

For most scenarios the RegexFilter will be sufficient to filter out certain messages. The following sample configuration is the default used by GemFire plus a RegexFilter to avoid logging errors containing [TEXT IN LOG ENTRY]:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
    <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} &lt;%thread&gt; tid=%tid] %message%n%throwable%n</Property>
    <Console name="STDOUT" target="SYSTEM_OUT">
      <PatternLayout pattern="${gemfire-pattern}"/>
    <Logger name="com.gemstone" level="INFO" additivity="true">
        <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
        <RegexFilter regex=".*[TEXT IN LOG ENTRY].*" onMatch="DENY" onMismatch="NEUTRAL"/>
    <Root level="ERROR">
      <AppenderRef ref="STDOUT"/>

To override the default configuration used by GemFire, start up the servers using the system property log4j.configurationFile pointing to a local log4j configuration file, as an example:

gfsh start server --name=name --J=-Dlog4j.configurationFile=/config/log4j2-custom.xml.


More information about Log4j filters can be found at the Apache Log4J project.


Powered by Zendesk