From b62424c9698cec975ee8bb7e6c3086b912a24724 Mon Sep 17 00:00:00 2001 From: aarshi Date: Mon, 29 Jan 2024 13:27:13 +0530 Subject: [PATCH] Get logs in json format --- .../src/main/java/org/apache/atlas/service/Services.java | 7 ++----- .../apache/atlas/repository/audit/StartupTimeLogger.java | 9 +++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/org/apache/atlas/service/Services.java b/common/src/main/java/org/apache/atlas/service/Services.java index f380b4afca..d1c5d37ccc 100644 --- a/common/src/main/java/org/apache/atlas/service/Services.java +++ b/common/src/main/java/org/apache/atlas/service/Services.java @@ -18,6 +18,7 @@ package org.apache.atlas.service; import org.apache.atlas.annotation.AtlasService; +import org.apache.atlas.type.AtlasType; import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.commons.configuration.Configuration; import org.apache.commons.lang.StringUtils; @@ -89,7 +90,6 @@ public void start() { durationMap.putIfAbsent(svc.getClass().getName(),Duration.between(start, end).toMillis()); } - LOG.info("Capturing Service startup time"); printHashMapInTableFormatDescendingOrder(durationMap, "startupTime"); } catch (Exception e) { @@ -158,9 +158,6 @@ public static void printHashMapInTableFormatDescendingOrder(Map ma LOG.info(System.out.printf(rowFormat, "Key", value).toString()); LOG.info(new String(new char[maxKeyLength + 15]).replace('\0', '-')); - // Print each sorted entry - for (Map.Entry entry : list) { - LOG.info(System.out.printf(rowFormat, entry.getKey(), entry.getValue()).toString()); - } + LOG.info("Capturing Service startup time {}", AtlasType.toJson(list)); } } diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/StartupTimeLogger.java b/repository/src/main/java/org/apache/atlas/repository/audit/StartupTimeLogger.java index b50db130bb..ebe0a0b50f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/audit/StartupTimeLogger.java +++ b/repository/src/main/java/org/apache/atlas/repository/audit/StartupTimeLogger.java @@ -1,6 +1,8 @@ package org.apache.atlas.repository.audit; +import org.apache.atlas.type.AtlasType; import org.apache.atlas.utils.AtlasPerfTracer; +import org.apache.commons.logging.Log; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationListener; @@ -24,8 +26,6 @@ public StartupTimeLogger(StartupTimeLoggerBeanPostProcessor beanPostProcessor) { @Override public void onApplicationEvent(ContextRefreshedEvent event) { // Print the startup times after all beans are loaded - - LOG.info("Capturing Bean creation time"); printHashMapInTableFormatDescendingOrder(beanPostProcessor.getDurationTimeMap(), "creationTime"); } @@ -46,9 +46,6 @@ public static void printHashMapInTableFormatDescendingOrder(Map ma LOG.info(System.out.printf(rowFormat, "Key", value).toString()); LOG.info(new String(new char[maxKeyLength + 1]).replace('\0', '-')); - // Print each sorted entry - for (Map.Entry entry : list) { - LOG.info(System.out.printf(rowFormat, entry.getKey(), entry.getValue()).toString()); - } + LOG.info("Capturing Bean creation time {}", AtlasType.toJson(list)); } } \ No newline at end of file