How to filter GemFire logs in 8.0 and later
search cancel

How to filter GemFire logs in 8.0 and later

book

Article ID: 294280

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

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.

Environment


Resolution

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">
   <Properties>
     <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>
   </Properties>
   <Appenders>
     <Console name="STDOUT" target="SYSTEM_OUT">
       <PatternLayout pattern="${gemfire-pattern}"/>
     </Console>
   </Appenders>
   <Loggers>
     <Logger name="com.gemstone" level="INFO" additivity="true">
       <filters>
         <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
         <RegexFilter regex=".*[TEXT IN LOG ENTRY].*" onMatch="DENY" onMismatch="NEUTRAL"/>
       </filters>
     </Logger>
     <Root level="ERROR">
       <AppenderRef ref="STDOUT"/>
     </Root>
   </Loggers>
 </Configuration>

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.



Additional Information

Applies to

GemFire 8.0 and later

Reference

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