From 0fd28d28cda635eed9dff1a1680cd80b5405bee6 Mon Sep 17 00:00:00 2001 From: shedfreewu <49236872+shedfreewu@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:32:07 +0800 Subject: [PATCH] refactor: optimize log (#1671) --- CHANGELOG.md | 3 ++- .../com/tencent/cloud/common/metadata/MetadataContext.java | 2 +- .../cloud/common/util/ApplicationContextAwareUtils.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b061a4337..34fa34449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,5 @@ - [fix: fix ConfigChangeListener and unit test](https://github.com/Tencent/spring-cloud-tencent/pull/1657) - [fix: fix ConfigChangeListener ut bug](https://github.com/Tencent/spring-cloud-tencent/pull/1663) - [fix: tsf 2024 related bugfixes](https://github.com/Tencent/spring-cloud-tencent/pull/1664) -- [fix: remove conflict dependencies management](https://github.com/Tencent/spring-cloud-tencent/pull/1669) \ No newline at end of file +- [fix: remove conflict dependencies management](https://github.com/Tencent/spring-cloud-tencent/pull/1669) +- [refactor: optimize log](https://github.com/Tencent/spring-cloud-tencent/pull/1671) \ No newline at end of file diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java index 392ce53b4..6d86e6d04 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/MetadataContext.java @@ -118,7 +118,7 @@ public class MetadataContext extends com.tencent.polaris.metadata.core.manager.M .getProperties("spring.application.name", null)); } if (!StringUtils.hasText(serviceName)) { - LOG.error("service name should not be blank. please configure spring.cloud.polaris.service or " + LOG.warn("service name should not be blank. please configure spring.cloud.polaris.service or " + "spring.cloud.polaris.discovery.service or spring.application.name"); } serviceName = DiscoveryUtil.rewriteServiceId(serviceName); diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/ApplicationContextAwareUtils.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/ApplicationContextAwareUtils.java index fe252e193..3fd921776 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/ApplicationContextAwareUtils.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/ApplicationContextAwareUtils.java @@ -59,7 +59,7 @@ public class ApplicationContextAwareUtils implements ApplicationContextAware { if (applicationContext != null) { return applicationContext.getEnvironment().getProperty(key); } - LOGGER.warn("applicationContext is null, try to get property from System.getenv or System.getProperty"); + LOGGER.warn("applicationContext is null, try to get property({}} from System.getenv or System.getProperty", key); String property = System.getenv(key); if (StringUtils.isBlank(property)) { property = System.getProperty(key); @@ -77,7 +77,7 @@ public class ApplicationContextAwareUtils implements ApplicationContextAware { if (applicationContext != null) { return applicationContext.getEnvironment().getProperty(key, defaultValue); } - LOGGER.warn("applicationContext is null, try to get property from System.getenv or System.getProperty"); + LOGGER.warn("applicationContext is null, try to get property({}} from System.getenv or System.getProperty", key); String property = System.getenv(key); if (StringUtils.isBlank(property)) { property = System.getProperty(key, defaultValue);