|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<E>
ch.qos.logback.ext.loggly.AbstractLogglyAppender<E>
ch.qos.logback.ext.loggly.LogglyBatchAppender<E>
public class LogglyBatchAppender<E>
Logback batch appender for Loggly HTTP API.
Note:Loggly's Syslog API is much more scalable than the HTTP API which should mostly be used in low-volume or non-production systems. The HTTP API can be very convenient to workaround firewalls.
If the LogglyBatchAppender saturates and discards log messages, the following warning message is
appended to both Loggly and System.err:
"$date - OutputStream is full, discard previous logs"
| Property Name | Type | Description |
|---|---|---|
| inputKey | String | Loggly input key. "inputKey" or endpointUrl is required. Sample
"12345678-90ab-cdef-1234-567890abcdef" |
| endpointUrl | String | Loggly HTTP API endpoint URL. "inputKey" or endpointUrl is required. Sample:
"https://logs.loggly.com/inputs/12345678-90ab-cdef-1234-567890abcdef" |
| pattern | String | Pattern used for Loggly log messages. Default value is:
%d{"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",UTC} %-5level [%thread] %logger: %m%n. |
| proxyHost | String | hostname of a proxy server. If blank, no proxy is used (See URL.openConnection(java.net.Proxy). |
| proxyPort | int | port of a proxy server. Must be a valid int but is ignored if proxyHost is blank or null. |
| jmxMonitoring | boolean | Enable registration of a monitoring MBean named
"ch.qos.logback:type=LogglyBatchAppender,name=LogglyBatchAppender@#hashcode#". Default: true. |
| maxNumberOfBuckets | int | Max number of buckets of in the byte buffer. Default value: 8. |
| maxBucketSizeInKilobytes | int | Max size of each bucket. Default value: 1024 Kilobytes (1MB). |
| flushIntervalInSeconds | int | Interval of the buffer flush to Loggly API. Default value: 3. |
| connReadTimeoutSeconds | int | How Long the HTTP Connection will wait on reads. Default value: 1 second. |
flushIntervalInSeconds parameter to "2s" or event "1s".
<configuration scan="true" scanPeriod="30 seconds" debug="true">
<if condition='isDefined("logback.loggly.inputKey")'>
<then>
<appender name="loggly" class="ch.qos.logback.ext.loggly.LogglyBatchAppender">
<inputKey>${logback.loggly.inputKey}</inputKey>
<pattern>%d{yyyy/MM/dd HH:mm:ss,SSS} [${HOSTNAME}] [%thread] %-5level %logger{36} - %m %throwable{5}%n</pattern>
<proxyHost>${logback.loggly.proxy.host:-}</proxyHost>
<proxyPort>${logback.loggly.proxy.port:-8080}</proxyPort>
<debug>${logback.loggly.debug:-false}</debug>
</appender>
<root level="WARN">
<appender-ref ref="loggly"/>
</root>
</then>
</if>
</configuration>
ch.qos.logback.core.read.CyclicBufferAppender and buffering the ILoggingEvent ?
Because it is much easier to control the size in memoryBufferedOutputStream on the HttpURLConnection ?
Because the Loggly API may not like such kind of streaming approach.
| Nested Class Summary | |
|---|---|
class |
LogglyBatchAppender.LogglyExporter
|
| Field Summary | |
|---|---|
static String |
ENDPOINT_URL_PATH
|
protected AtomicLong |
sendDurationInNanos
|
protected AtomicInteger |
sendExceptionCount
|
protected AtomicInteger |
sendSuccessCount
|
protected AtomicLong |
sentBytes
|
| Fields inherited from class ch.qos.logback.ext.loggly.AbstractLogglyAppender |
|---|
DEFAULT_ENDPOINT_PREFIX, DEFAULT_LAYOUT_PATTERN, endpointUrl, inputKey, layout, layoutCreatedImplicitly, proxy, UTF_8 |
| Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase |
|---|
name, started |
| Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase |
|---|
context |
| Constructor Summary | |
|---|---|
LogglyBatchAppender()
|
|
| Method Summary | |
|---|---|
protected void |
append(E eventObject)
|
long |
getCurrentLogEntriesBufferSizeInBytes()
Size in bytes of the log entries that have not yet been sent to Loggly. |
int |
getDiscardedBucketsCount()
Number of discarded buckets |
protected String |
getEndpointPrefix()
Returns the URL path prefix for the Loggly endpoint to which the implementing class will send log events. |
int |
getFlushIntervalInSeconds()
|
protected HttpURLConnection |
getHttpConnection(URL url)
Creates a configured HTTP connection to a URL (does not open the connection) |
long |
getSendDurationInNanos()
Duration spent sending logs to Loggly. |
int |
getSendExceptionCount()
Number of failing invocations to Loggly's send logs API. |
int |
getSendSuccessCount()
Number of successful invocations to Loggly's send logs API. |
long |
getSentBytes()
Number of bytes sent to Loggly. |
boolean |
isDebug()
|
void |
processLogEntries()
Send log entries to Loggly |
protected void |
processLogEntries(InputStream in)
Send log entries to Loggly |
void |
setConnReadTimeoutSeconds(int connReadTimeoutSeconds)
set method for Logback to allow Connection Read Timeout to be exposed |
void |
setDebug(boolean debug)
Enable debugging |
void |
setFlushIntervalInSeconds(int flushIntervalInSeconds)
|
void |
setJmxMonitoring(boolean jmxMonitoring)
|
void |
setMaxBucketSizeInKilobytes(int maxBucketSizeInKilobytes)
|
void |
setMaxNumberOfBuckets(int maxNumberOfBuckets)
|
void |
setMbeanServer(MBeanServer mbeanServer)
|
void |
start()
|
void |
stop()
|
| Methods inherited from class ch.qos.logback.ext.loggly.AbstractLogglyAppender |
|---|
buildEndpointUrl, createLayout, ensureLayout, getEndpointUrl, getHttpReadTimeoutInMillis, getInputKey, getLayout, getPattern, getProxyHost, getProxyPort, readResponseBody, setEndpointUrl, setHttpReadTimeoutInMillis, setInputKey, setLayout, setPattern, setProxyHost, setProxyPort, setProxyPort, toBytes |
| Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase |
|---|
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString |
| Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase |
|---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ch.qos.logback.core.spi.ContextAware |
|---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext |
| Field Detail |
|---|
public static final String ENDPOINT_URL_PATH
protected final AtomicLong sendDurationInNanos
protected final AtomicLong sentBytes
protected final AtomicInteger sendSuccessCount
protected final AtomicInteger sendExceptionCount
| Constructor Detail |
|---|
public LogglyBatchAppender()
| Method Detail |
|---|
protected void append(E eventObject)
append in class ch.qos.logback.core.UnsynchronizedAppenderBase<E>public void start()
start in interface ch.qos.logback.core.spi.LifeCyclestart in class AbstractLogglyAppender<E>public void stop()
stop in interface ch.qos.logback.core.spi.LifeCyclestop in class AbstractLogglyAppender<E>public void processLogEntries()
processLogEntries in interface LogglyBatchAppenderMBean
protected HttpURLConnection getHttpConnection(URL url)
throws IOException
url - target URL
IOException
protected void processLogEntries(InputStream in)
throws IOException
IOExceptionpublic int getFlushIntervalInSeconds()
public void setFlushIntervalInSeconds(int flushIntervalInSeconds)
public long getSentBytes()
LogglyBatchAppenderMBean
getSentBytes in interface LogglyBatchAppenderMBeanpublic long getSendDurationInNanos()
LogglyBatchAppenderMBean
getSendDurationInNanos in interface LogglyBatchAppenderMBeanpublic int getSendSuccessCount()
LogglyBatchAppenderMBean
getSendSuccessCount in interface LogglyBatchAppenderMBeanpublic int getSendExceptionCount()
LogglyBatchAppenderMBean
getSendExceptionCount in interface LogglyBatchAppenderMBeanpublic int getDiscardedBucketsCount()
LogglyBatchAppenderMBean
getDiscardedBucketsCount in interface LogglyBatchAppenderMBeanpublic long getCurrentLogEntriesBufferSizeInBytes()
LogglyBatchAppenderMBean
getCurrentLogEntriesBufferSizeInBytes in interface LogglyBatchAppenderMBeanpublic void setDebug(boolean debug)
LogglyBatchAppenderMBean
setDebug in interface LogglyBatchAppenderMBeanpublic boolean isDebug()
isDebug in interface LogglyBatchAppenderMBeanpublic void setJmxMonitoring(boolean jmxMonitoring)
public void setMbeanServer(MBeanServer mbeanServer)
public void setMaxNumberOfBuckets(int maxNumberOfBuckets)
public void setMaxBucketSizeInKilobytes(int maxBucketSizeInKilobytes)
public void setConnReadTimeoutSeconds(int connReadTimeoutSeconds)
protected String getEndpointPrefix()
AbstractLogglyAppenderAbstractLogglyAppender.DEFAULT_ENDPOINT_PREFIX with the
endpoint prefix from AbstractLogglyAppender.getEndpointPrefix() and the
AbstractLogglyAppender.inputKey.
getEndpointPrefix in class AbstractLogglyAppender<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||