DEV Community

Karthikeyan Sadayamuthu for devxchange

Posted on • Updated on


LogMetrics framework for Microservices (Java)— part 1

Alt Text

LogMetrics Framework provides simplified configuration to log payload and metrics data.

Maven Repo
maven { url ""}


compile ("io.devxchange:logmetrics:0.0.2")
Enable logmetrics — Add below property to your file
logmetrics.logging.obfuscate.md5.fields= #comma seperated fields
logmetrics.logging.obfuscate.sha256.fields= #comma seperated fields
logmetrics.logging.obfuscate.fields= #comma seperated fields

SpringBoot Application

@ComponentScan(basePackages = { "io.devxchange.logmetrics.demo", "io.devxchange.logmetrics" })
public class LoggingDemoApplication {

   public static void main(String[] args) {, args);

Injecting the LogWriterManager & adding Interceptors

public class AppConfig extends WebMvcConfigurerAdapter {

   private LogWriterManager logWriterManager;

   public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(new FrontendRestInterceptor(logWriterManager));

LogMetrics json schema

  "$schema": "",
  "type": "LogMetrics",
  "properties": {
    "Node": {
      "type": "string",
      "description": "Application Host IP Address"
    "message_type": {
      "type": "string",
      "description": "Logmetrics message type",
      "value": "LOGMETRICS_MESSAGE"
    "Duration": {
      "type": "integer",
      "description": "Response time of the API"
    "Host": {
      "type": "string",
      "description": "Application Host Name"
    "Fault": {
      "type": "boolean",
      "description": "API Success or Failed status "
    "Method": {
      "type": "string",
      "description": "API Method name"
    "ResponseBody": {
      "type": "string",
      "description": "API Response Body"
    "StartDateTime": {
      "type": "string",
      "description": "API Start Time"
    "EndDateTime": {
      "type": "string",
      "description": "API End time"
    "HttpMethod": {
      "type": "string",
      "description": "Http Method Type"
    "RequestBody": {
      "type": "string",
      "description": "API Request Body"

sample logmetrics message

  "Node": "",
  "message_type": "LOGMETRICS_MESSAGE",
  "Duration": 106,
  "Host": "hostname",
  "Fault": false,
  "Method": "/user-service/api/v1/user/{id}",
  "ResponseBody": "{\"id\":1,\"name\":\"02adcec2263d2127269fcd769c33f029\",\"age\":\"35135aaa6cc23891b40cb3f378c53a17a1127210ce60e125ccf03efcfdaec458\",\"salary\":\"********\"}",
  "StartDateTime": "Tue Nov 26 23:22:54 EST 2019",
  "EndDateTime": "Tue Nov 26 23:22:54 EST 2019",
  "HttpMethod": "GET",
  "RequestBody": ""

Demo Project

Alt Text


Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git