Skip to content

1.5.2

Compare
Choose a tag to compare
@sndyuk sndyuk released this 22 Feb 15:43
· 86 commits to master since this release

1. Added CloudWatchLogbackAppender. Please refer to the sample configuration:

https://github.com/sndyuk/logback-more-appenders/blob/master/src/test/resources/logback-appenders.xml

<appender name="CLOUDWATCH_SYNC"
    class="ch.qos.logback.more.appenders.CloudWatchLogbackAppender">

    <awsConfig>
      <!-- [Optional] Place AwsCredentials.properties in class path. -->
      <credentialFilePath>AwsCredentials.properties</credentialFilePath>
      <region>ap-northeast-1</region>
    </awsConfig>
    <logGroupName>test-log</logGroupName>
    <!-- [Optional] Automatically roll current log stream and resume logging in a new stream. -->
    <logStreamRolling class="ch.qos.logback.more.appenders.CountBasedStreamName">
      <!-- The limit is not exactly checked. The stream can have more than the limit depends on emitInterval and maxFlushTime. -->
      <limit>100000</limit>
    </logStreamRolling>
    <!-- [Optional] Or you can specify static stream name.
    <logStreamName>my-log-stream</logStreamName>
    -->
    <!-- [Optional] Create Log group and stream automatically. -->
    <createLogDestination>true</createLogDestination>
    <!-- The minimum interval millis for each CloudWatch API call. -->
    <emitInterval>100</emitInterval>

    <encoder>
      <pattern><![CDATA[[%thread] %-5level %logger{15}#%line %msg]]></pattern>
    </encoder>
  </appender>

  <appender name="CLOUDWATCH" class="ch.qos.logback.classic.AsyncAppender">
    <!-- Max queue size of logs which is waiting to be sent (When it reach to the max size, the log will be disappeared). -->
    <queueSize>999</queueSize>
    <!-- Never block when the queue becomes full. -->
    <neverBlock>true</neverBlock>
    <!-- The default maximum queue flush time allowed during appender stop. 
         If the worker takes longer than this time it will exit, discarding any remaining items in the queue.
         10000 millis
     -->
   <maxFlushTime>100</maxFlushTime>
    <appender-ref ref="CLOUDWATCH_SYNC" />
  </appender>

2. Accept dynamic Map<String, ?> as the additional log property. #32

        Map<String, String> map = new HashMap<String, String>();
        map.put("key1", "value1");
        map.put("key2", "value2");

        MapMarker mapMarker = new MapMarker("MAP_MARKER", map);

        LOG.debug(mapMarker, "Test the marker map.");

3. Added simple marker filter for Appender. #33

  <appender ...>
    <!-- The simple marker filter instead of writing complex configuration with EvaluatorFilter -->
    <filter class="ch.qos.logback.more.appenders.filter.AppendersMarkerFilter">
      <marker>SECURITY_ALERT</marker>
    </filter>
    ...