From 8a0cc1ba1cfc00a3e4460fb72aa940e9766bf256 Mon Sep 17 00:00:00 2001 From: pnoker Date: Wed, 30 Apr 2025 16:27:02 +0800 Subject: [PATCH] build: add logstash-logback dependency and update logging configuration Add Logstash Logback dependency to enable JSON logging and update the logback.xml configuration to include a JSON encoder. Also, update the CI workflow to cache Maven packages and improve build performance by disabling transfer progress. --- .github/workflows/docker-ci.yml | 11 ++++- dc3-common/dc3-common-log/pom.xml | 11 +++++ .../src/main/resources/logback.xml | 46 ++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 5e66af9dd..f85b8df4a 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -16,6 +16,15 @@ jobs: distribution: liberica java-version: 21 cache: maven + cache-dependency-path: "**/pom.xml" + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-m2- - name: Extract Variables id: variables @@ -51,7 +60,7 @@ jobs: echo "docker_registry_aliyun=registry.cn-beijing.aliyuncs.com/dc3" >> $GITHUB_OUTPUT - name: Build with Maven - run: mvn -U -e -B clean package -DskipTests -P ${{ steps.variables.outputs.profile }} + run: mvn -U -e -B clean package -DskipTests -P ${{ steps.variables.outputs.profile }} --no-transfer-progress - name: List Workspace run: | diff --git a/dc3-common/dc3-common-log/pom.xml b/dc3-common/dc3-common-log/pom.xml index abf4de11b..471e19dc8 100644 --- a/dc3-common/dc3-common-log/pom.xml +++ b/dc3-common/dc3-common-log/pom.xml @@ -65,6 +65,10 @@ https://github.com/pnoker/iot-dc3.git + + 8.1 + + @@ -79,6 +83,13 @@ aspectjweaver + + + net.logstash.logback + logstash-logback-encoder + ${logstash.logback.version} + + \ No newline at end of file diff --git a/dc3-common/dc3-common-log/src/main/resources/logback.xml b/dc3-common/dc3-common-log/src/main/resources/logback.xml index 8e2e3de6f..627f6e031 100644 --- a/dc3-common/dc3-common-log/src/main/resources/logback.xml +++ b/dc3-common/dc3-common-log/src/main/resources/logback.xml @@ -22,13 +22,55 @@ value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} [%clr(%4line){magenta}] %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"/> - + - + + + + + + ${FILE_LOG_THRESHOLD} + + + ${FILE_LOG_PATTERN} + ${FILE_LOG_CHARSET} + + ${LOG_FILE} + + ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} + ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} + ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} + ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} + ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7} + + + + + + timestamp + Asia/Shanghai + + + version + + + + + + + + + + + + + + +