tnt4j-logback

Logback Appender for TNT4J

Logback Appender

All Logback messages can be routed to TNt4J event sinks via com.nastel.jkool.tnt4j.logger.logback.TNT4JAppender, which allows developers to send event messages to TNT4J.

Developers may also enrich event messages and pass context to TNT4J using hash tag enrichment scheme. Hash tags are used to decorate event messages with important meta data about each log message. This meta data is used to generate TNT4J tracking events:

logger.info("Starting a tnt4j activity #beg=Test, #app=" + Log4JTest.class.getName());
logger.warn("First log message #app=" + Log4JTest.class.getName() + ", #msg='1 Test warning message'");
logger.error("Second log message #app=" + Log4JTest.class.getName() + ", #msg='2 Test error message'", new Exception("test exception"));
logger.info("Ending a tnt4j activity #end=Test, #app=" + Log4JTest.class.getName() + " #%i/order-no=" + orderNo  + " #%d:currency/amount=" + amount);

Above example groups messages between first and last into a related logical collection called Activity. Activity is a collection of logically related events/messages. Hash tags #beg, #end are used to demarcate activity boundaries. This method also supports nested activities.

User defined fields can be reported using #[data-type][:value-type]/your-metric-name=your-value convention (e.g. #%i/order-no=62627 or #%d:currency/amount=50.45). TNT4JAppender supports the following optional data-type qualifiers:

    %i/ -- integer
    %l/ -- long
    %d/ -- double
    %f/ -- float
    %b/ -- boolean
    %n/ -- number
    %s/ -- string

All value-type qualifiers are defined in com.nastel.jkool.tnt4j.core.ValueTypes. Examples:

    currency    -- generic currency
    flag        -- boolean flag
    age         -- age in time units
    guid        -- globally unique identifier
    guage       -- numeric gauge
    counter     -- numeric counter
    percent     -- percent
    timestamp   -- timestamp
    addr        -- generic address

Not specifying a qualifier defaults to auto detection of type by TNT4JAppender. First number qualifier is tested and defaults to string if the test fails (e.g. #order-no=62627). User defined fields are reported as a TNT4J snapshot with Logback category and snapshot name set to activity name set by #beg, #end, #opn tags.

Below are Logback appender configuration attributes with defaults:

appender.class=com.nastel.jkool.tnt4j.logger.logback.TNT4JAppender
SourceName=com.logback
SourceType=APPL
MetricsOnException=true
MetricsFrequency=60

TNT4J Command line options

Command line arguments:

See <timestamp>.log and <vmid>.dump file for output produced by running your applications with this appender. See config/tnt4j.properties for TNT4J configuration: factories, formatters, listeners, etc.

How to Build tnt4j-logback

Requirements

TNT4J-LOGBACK depends on the following external packages: