Giter VIP home page Giter VIP logo

activemq-mdc's Introduction

A plugin to add our own MDC fields to logging

  • This is an external plugin which extends ActiveMQ's default LoggingBrokerPlugin and will be added to ActiveMQ's broker filter chain.
  • Using this plugin, it is now possible to add our own MDC values into the ActiveMQ logging which is not supported natively.

Usage

Build

  • Running mvn clean package will produce two artifacts activemq-mdc.jar and activemq-mdc.zip

Add runtime dependency to lib directory

  • Add these activemq-mdc.jar,jsonevent-layout-1.7.jar, json-smart-2.3.jar, accessors-smart-1.2.jar to ${ACTIVEME_HOME}/lib directory
  • For convenience, the required jars are assembled in this activemq-mdc.zip archive which can be extracted inside /lib.
  • The three other jars except activemq-mdc.jar are required to produce logging in JSON layout. Further, the JSON file can be fed directly into JSON log parsers like logstash and viewed using ElasticSearch. Those jars can be skipped if JSON layout is not required.

Modify ActiveMQ broker configuration

  • Add below bean configuration to activemq.xml inside <plugins> section.
  • The properties can be modified according to our needs.
  • Sample configuration is here
        <bean xmlns="http://www.springframework.org/schema/beans"
                   id="extendedLoggingPlugin"
                   class="com.lunatech.activemq.plugin.ExtendedLoggingBrokerPlugin">
               <property name="logAll" value="false"/>
               <property name="logConnectionEvents" value="false"/>
               <property name="logTransactionEvents" value="true"/>
               <property name="logConsumerEvents" value="true"/>
               <property name="logProducerEvents" value="true"/>
         </bean>

Configure file appender

  • Use this File appender configuration in log4j.properties under ${ActiveMQ_HOME}/conf directory.
  • Do not forget to add this appender to logger.rootLogger.
  • Sample configuration is here
log4j.appender.jsonfile=org.apache.log4j.RollingFileAppender
log4j.appender.jsonfile.file=/var/log/activemq/activemq.json
log4j.appender.jsonfile.encoding=UTF-8
log4j.appender.jsonfile.maxFileSize=10MB
log4j.appender.jsonfile.maxBackupIndex=5
log4j.appender.jsonfile.append=true
log4j.appender.jsonfile.DatePattern=.yyyy-MM-dd
log4j.appender.jsonfile.layout=net.logstash.log4j.JSONEventLayoutV1

What can you expect?

You should be able to find the following additional MDC fields in your log message.

  "mdc": {
    "sent-to-DLQ": "false",
    "redelivery-count": "0",
    "producer-id": "ID:Sasikumars-MacBook-Pro.local-59587-1538170787867-4:1:1:1",
    "message-body": "{\"propertyName\":\"propertyValue\"}",
    "client-id": "ID:Sasikumars-MacBook-Pro.local-59587-1538170787867-3:1",
    "message-id": "ID:Sasikumars-MacBook-Pro.local-59587-1538170787867-4:1:1:1:1",
    "activemq.connector": "vm:\/\/unit-test",
    "destination": "unit.test.q",
    "is-redelivered": "false"
  }

activemq-mdc's People

Contributors

sasikumar-swaminathan avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.