Created
August 8, 2016 04:48
-
-
Save monkey-codes/518fac0010645cb382a5479ab8a28641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ch.qos.logback.core.ConsoleAppender | |
import codes.monkey.logging.BeanStalkPropertyDefiner | |
import codes.monkey.logging.LoggingTagsPropertyDefiner | |
import net.logstash.logback.appender.LoggingEventAsyncDisruptorAppender | |
import net.logstash.logback.stacktrace.ShortenedThrowableConverter | |
import codes.monkey.logging.TimestampFormatPropertyDefiner.CloudwatchLogstashEncoder | |
import groovy.json.JsonOutput | |
def tag = { name -> new LoggingTagsPropertyDefiner(property: name).getPropertyValue() } | |
def beanstalk = { name -> new BeanStalkPropertyDefiner(field: name).getPropertyValue() } | |
def loggingMarkers = JsonOutput.toJson([ | |
app_name : tag('app.name'), | |
app_version: tag('app.version'), | |
eb_hostname: beanstalk('hostname'), | |
eb_instance_id: beanstalk('instance-id'), | |
eb_instance_type: beanstalk('instance-type'), | |
eb_ip: beanstalk('local-ipv4') | |
]) | |
appender('root', LoggingEventAsyncDisruptorAppender) { | |
appender(ConsoleAppender) { | |
encoder(CloudwatchLogstashEncoder) { | |
customFields = loggingMarkers | |
shortenedLoggerNameLength = 36 | |
throwableConverter(ShortenedThrowableConverter) { | |
maxDepthPerThrowable = 30 | |
maxLength = 2048 | |
shortenedClassNameLength = 20 | |
excludes = ['sun\\.reflect\\..*\\.invoke.*', | |
'net\\.sf\\.cglib\\.proxy\\.MethodProxy\\.invoke'] | |
rootCauseFirst = true | |
} | |
} | |
} | |
} | |
root(INFO, ['root']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment