public class GelfLayout<E extends ch.qos.logback.classic.spi.ILoggingEvent>
extends ch.qos.logback.core.LayoutBase<E>
| Constructor and Description |
|---|
GelfLayout() |
| 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.
|
String |
doLayout(E event) |
Map<String,String> |
getAdditionalFields()
additional fields to add to the gelf message.
|
Map<String,String> |
getFieldTypes() |
ch.qos.logback.core.Layout |
getFullMessageLayout() |
String |
getHost()
Override the local host using a config option
|
ch.qos.logback.core.Layout |
getShortMessageLayout() |
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 |
setFieldTypes(Map<String,String> fieldTypes) |
void |
setFullMessageLayout(ch.qos.logback.core.Layout fullMessageLayout) |
void |
setHost(String host) |
void |
setIncludeFullMDC(boolean includeFullMDC) |
void |
setShortMessageLayout(ch.qos.logback.core.Layout shortMessageLayout) |
void |
setStaticAdditionalFields(Map<String,String> staticAdditionalFields) |
void |
setUseLoggerName(boolean useLoggerName) |
void |
setUseMarker(boolean useMarker) |
void |
setUseThreadName(boolean useThreadName) |
void |
start() |
getContentType, getContext, getFileFooter, getFileHeader, getPresentationFooter, getPresentationHeader, isStarted, setContext, setFileFooter, setFileHeader, setPresentationFooter, setPresentationHeader, stopaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getDeclaredOrigin, getStatusManagerpublic void start()
start in interface ch.qos.logback.core.spi.LifeCyclestart in class ch.qos.logback.core.LayoutBase<E extends ch.qos.logback.classic.spi.ILoggingEvent>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 getHost()
public void setHost(String host)
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 ch.qos.logback.core.Layout getFullMessageLayout()
public void setFullMessageLayout(ch.qos.logback.core.Layout fullMessageLayout)
public ch.qos.logback.core.Layout getShortMessageLayout()
public void setShortMessageLayout(ch.qos.logback.core.Layout shortMessageLayout)
Copyright © 2011–2015. All rights reserved.