Stackify Log Appender for Log4j 2.x
Clone or download

README.md

stackify-log-log4j2

Maven Central Build Status Coverage Status

Log4j 2.x appender for sending log messages and exceptions to Stackify.

Errors and Logs Overview:

http://support.stackify.com/errors-and-logs-overview/

Sign Up for a Trial:

http://www.stackify.com/sign-up/

Installation

Add it as a maven dependency:

<dependency>
    <groupId>com.stackify</groupId>
    <artifactId>stackify-log-log4j2</artifactId>
    <version>INSERT_LATEST_MAVEN_CENTRAL_VERSION</version>
    <scope>runtime</scope>
</dependency>

Usage

Example configuration:

<Configuration packages="com.stackify.log.log4j2">
    <Appenders>
        <StackifyLog name="STACKIFY" apiKey="YOUR_API_KEY" application="YOUR_APPLICATION_NAME" environment="YOUR_ENVIRONMENT"/>
        ...
    </Appenders>
    <Loggers>
        <Root ...>
            ...
            <AppenderRef ref="STACKIFY"/>
        </Root>
    </Loggers>
</Configuration>

Note: If you are logging from a device that has the stackify-agent installed, the environment setting is optional. We will use the environment associated to your device in Stackify.

Be sure to shutdown Log4j to flush this appender of any errors and shutdown the background thread:

((org.apache.logging.log4j.core.LoggerContext) org.apache.logging.log4j.LogManager.getContext(false)).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 <StackifyLog> ... </StackifyLog> tag.

Customize Masking:

The example below has the following customizations:

  1. Credit Card value masking is disabled (<Mask enabled="false">CREDITCARD</Mask>)
  2. IP Address masking is enabled (<Mask enabled="true">IP</Mask>). Built in masks are CREDITCARD, SSN and IP.
  3. Custom masking to remove vowels using a regex (<Mask enabled="true">[aeiou]</Mask>)
<Configuration packages="com.stackify.log.log4j2">
    <Appenders>
        <StackifyLog name="STACKIFY" apiKey="YOUR_API_KEY" application="YOUR_APPLICATION_NAME" environment="YOUR_ENVIRONMENT">
            <MaskEnabled>true</MaskEnabled>
            <Mask enabled="false">CREDITCARD</Mask>
            <Mask enabled="true">SSN</Mask>
            <Mask enabled="true">IP</Mask>
            <Mask enabled="true">[aeiou]</Mask>
        </StackifyLog>
        ...
    </Appenders>
    <Loggers>
        <Root ...>
            ...
            <AppenderRef ref="STACKIFY"/>
        </Root>
    </Loggers>
</Configuration>

License

Copyright 2015 Stackify, LLC.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.