Skip to content

Instantly share code, notes, and snippets.

@monkey-codes
Created August 8, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkey-codes/518fac0010645cb382a5479ab8a28641 to your computer and use it in GitHub Desktop.
Save monkey-codes/518fac0010645cb382a5479ab8a28641 to your computer and use it in GitHub Desktop.
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