Configure Logback
  • 1 Minute to read
  • Dark
    Light
  • PDF

Configure Logback

  • Dark
    Light
  • PDF

Article summary

Downloads and Includes

The stackify-log-logback project is open source and hosted on GitHub here.

Maven artifacts are available in the central Maven repository within a few hours after a new release.

https://search.maven.org/#search%7Cga%7C1%7CStackify

The group id is com.stackify. The artifact id is stackify-log-logback. Substitute the version number you wish to use in the dependency snippet below.

<dependency>
    <groupId>com.stackify</groupId>
    <artifactId>stackify-log-logback</artifactId>
    <version>1.0.5</version>
</dependency>

Configuration

<appender name="STACKIFY" class="com.stackify.log.logback.StackifyLogAppender">
    <apiKey>YOUR_ACTIVATION_KEY</apiKey>
    <application>YOUR_APPLICATION_NAME</application>
    <environment>YOUR_ENVIRONMENT</environment>
</appender>
...
<root level=...>
    ...
    <appender-ref ref="STACKIFY" />
</root>

Be sure to shut down Logback to flush this appender of any errors and shut down the background thread:

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.stop();

Masking

The Stackify appender has built-in data masking for credit cards and social security number values.

Enable Masking:

Add <maskEnabled>true</maskEnabled> inside the <appender> ... </appender> tag.

Customize Masking:

The example below has the following customizations:

  1. Credit Card value masking is disabled (<maskCreditCard>false</maskCreditCard>)
  2. IP Address masking is enabled (<maskIP>true</maskIP>).
  3. Custom masking to remove vowels using a regex (<maskCustom>[aeiou]</maskCustom>)
<appender name="STACKIFY" class="com.stackify.log.logback.StackifyLogAppender">
    <apiKey>YOUR_API_KEY</apiKey>
    <application>YOUR_APPLICATION_NAME</application>
    <environment>YOUR_ENVIRONMENT</environment>
      
    <maskEnabled>true</maskEnabled>
    <maskCreditCard>false</maskCreditCard>
    <maskSSN>true</maskSSN>
    <maskIP>true</maskIP>
    <maskCustom>[aeiou]</maskCustom> 
</appender>

Sending Logs Through a Proxy

If you are wanting to send your logs into Stackify through a proxy, you will want to set the 'https.proxyHost' and 'https.proxyPort' system properties. If both of these properties are set in your app, your logs go through the proxy specified.

Advanced Features: MDC, and NDC

If you're utilizing MDC (Mapped Diagnostic Context), Stackify will automatically pick up and report any data you add via MDC. This information will be available to you under the Custom Properties heading in the error details screen within Retrace.


Was this article helpful?