All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.logging.common.DropwizardLayout Maven / Gradle / Ivy

package io.dropwizard.logging.common;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;

import java.util.Map;
import java.util.TimeZone;

/**
 * A base layout for Dropwizard.
 * 
    *
  • Disables pattern headers.
  • *
  • Prefixes logged exceptions with {@code !}.
  • *
  • Sets the pattern to the given timezone.
  • *
*/ public class DropwizardLayout extends PatternLayout { public DropwizardLayout(LoggerContext context, TimeZone timeZone) { super(); setOutputPatternAsHeader(false); Map defaultConverterMap = getDefaultConverterMap(); defaultConverterMap.put("dwEx", PrefixedThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwException", PrefixedThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwThrowable", PrefixedThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwREx", PrefixedRootCauseFirstThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwRootException", PrefixedRootCauseFirstThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwXEx", PrefixedExtendedThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwXException", PrefixedExtendedThrowableProxyConverter.class.getName()); defaultConverterMap.put("dwXThrowable", PrefixedExtendedThrowableProxyConverter.class.getName()); setPattern("%-5p [%d{ISO8601," + timeZone.getID() + "}] %c: %m%n%dwREx"); setContext(context); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy