public class GelfAppender
extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
| Constructor and Description |
|---|
GelfAppender() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAdditionalField(String keyValue)
Add an additional field.
|
void |
addFieldType(String keyValue) |
void |
addStaticAdditionalField(String keyValue)
Add a staticAdditional field.
|
protected void |
append(ch.qos.logback.classic.spi.ILoggingEvent logEvent)
The main append method.
|
Map<String,String> |
getAdditionalFields()
additional fields to add to the gelf message.
|
int |
getChunkThreshold() |
String |
getFacility()
The name of your service.
|
Map<String,String> |
getFieldTypes() |
String |
getGraylog2ServerHost()
The hostname of the graylog2 server to send messages to
|
int |
getGraylog2ServerPort()
The port of the graylog2 server to send messages to
|
String |
getGraylog2ServerVersion() |
String |
getHostName()
Override the local hostname using a config option
|
String |
getMessagePattern() |
int |
getShortMessageLength()
The length of the message to truncate to
|
String |
getShortMessagePattern() |
Map<String,String> |
getStaticAdditionalFields()
static additional fields to add to every gelf message.
|
boolean |
isIncludeFullMDC()
Indicates if all values from the MDC should be included in the gelf
message or only the once listed as
additional fields. |
boolean |
isUseLoggerName()
If true, an additional field call "_loggerName" will be added to each gelf message.
|
boolean |
isUseMarker() |
boolean |
isUseThreadName()
If true, an additional field call "_threadName" will be added to each gelf message.
|
void |
setAdditionalFields(Map<String,String> additionalFields) |
void |
setChunkThreshold(int chunkThreshold) |
void |
setFacility(String facility) |
void |
setFieldTypes(Map<String,String> fieldTypes) |
void |
setGraylog2ServerHost(String graylog2ServerHost) |
void |
setGraylog2ServerPort(int graylog2ServerPort) |
void |
setGraylog2ServerVersion(String graylog2ServerVersion) |
void |
setHostName(String hostName) |
void |
setIncludeFullMDC(boolean includeFullMDC) |
void |
setMessagePattern(String messagePattern) |
void |
setShortMessageLength(int shortMessageLength) |
void |
setShortMessagePattern(String shortMessagePattern) |
void |
setStaticAdditionalFields(Map<String,String> staticAdditionalFields) |
void |
setUseLoggerName(boolean useLoggerName) |
void |
setUseMarker(boolean useMarker) |
void |
setUseThreadName(boolean useThreadName) |
void |
start() |
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, stop, toStringaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextprotected void append(ch.qos.logback.classic.spi.ILoggingEvent logEvent)
append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>logEvent - The event that we are loggingpublic void start()
start in interface ch.qos.logback.core.spi.LifeCyclestart in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>public String getFacility()
public void setFacility(String facility)
public String getGraylog2ServerHost()
public void setGraylog2ServerHost(String graylog2ServerHost)
public int getGraylog2ServerPort()
public void setGraylog2ServerPort(int graylog2ServerPort)
public boolean isUseLoggerName()
public void setUseLoggerName(boolean useLoggerName)
public boolean isUseMarker()
public void setUseMarker(boolean useMarker)
public boolean isUseThreadName()
public void setUseThreadName(boolean useThreadName)
public Map<String,String> getAdditionalFields()
... MDC.put("ipAddress", "44.556.345.657"); ... Now, to
include the ip address in the gelf message, i just add the following to my logback.groovy:
appender("GELF", GelfAppender) { ... additionalFields = [identity:"_identity"] ... } in the
additionalFields map, the key is the name of the MDC to look up. the value is the name that should be given to
the key in the additional field in the gelf message.public Map<String,String> getStaticAdditionalFields()
public void setStaticAdditionalFields(Map<String,String> staticAdditionalFields)
public boolean isIncludeFullMDC()
additional fields.
If true, the gelf message will contain all values available
in the MDC. Each MDC key will be converted to a gelf custom field by
adding an underscore prefix. If an entry exists in
additional field it will be used instead.
If false, only the fields listed in
additional field will be included in the
message.
public void setIncludeFullMDC(boolean includeFullMDC)
public String getHostName()
public void setHostName(String hostName)
public void addAdditionalField(String keyValue)
keyValue - This must be in format key:value where key is the MDC key, and value is the GELF field
name. e.g "ipAddress:_ip_address"public void addStaticAdditionalField(String keyValue)
keyValue - This must be in format key:value where key is the additional field key, and value is a static
string. e.g "_node_name:www013"public void addFieldType(String keyValue)
public int getShortMessageLength()
public void setShortMessageLength(int shortMessageLength)
public String getGraylog2ServerVersion()
public void setGraylog2ServerVersion(String graylog2ServerVersion)
public int getChunkThreshold()
public void setChunkThreshold(int chunkThreshold)
public String getMessagePattern()
public void setMessagePattern(String messagePattern)
public String getShortMessagePattern()
public void setShortMessagePattern(String shortMessagePattern)
Copyright © 2011-2014. All Rights Reserved.