You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by do...@apache.org on 2022/05/20 05:19:09 UTC

[incubator-inlong] branch master updated: [INLONG-4235][Agent] Add log4j2 config file and fix the mock error of TestTextFileReader (#4237)

This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new ebff4a55b [INLONG-4235][Agent] Add log4j2 config file and fix the mock error of TestTextFileReader (#4237)
ebff4a55b is described below

commit ebff4a55bcf40727261db0f20253c12b54ede716
Author: Greedyu <de...@tencent.com>
AuthorDate: Fri May 20 13:19:04 2022 +0800

    [INLONG-4235][Agent] Add log4j2 config file and fix the mock error of TestTextFileReader (#4237)
---
 .../inlong/agent/plugin/sources/BinlogSource.java  |  2 +-
 .../agent/plugin/sources/TestTextFileReader.java   |  3 +-
 .../agent-plugins/src/test/resources/log4j2.xml    | 45 ++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/BinlogSource.java b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/BinlogSource.java
index c74a3726c..f13e1f49c 100644
--- a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/BinlogSource.java
+++ b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/BinlogSource.java
@@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicLong;
  */
 public class BinlogSource implements Source {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(TextFileSource.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(BinlogSource.class);
     private static final String BINLOG_SOURCE_TAG_NAME = "BinlogSourceMetric";
     private static AtomicLong metricsIndex = new AtomicLong(0);
     private final SourceMetrics sourceMetrics;
diff --git a/inlong-agent/agent-plugins/src/test/java/org/apache/inlong/agent/plugin/sources/TestTextFileReader.java b/inlong-agent/agent-plugins/src/test/java/org/apache/inlong/agent/plugin/sources/TestTextFileReader.java
index 849585e21..78e62a95d 100755
--- a/inlong-agent/agent-plugins/src/test/java/org/apache/inlong/agent/plugin/sources/TestTextFileReader.java
+++ b/inlong-agent/agent-plugins/src/test/java/org/apache/inlong/agent/plugin/sources/TestTextFileReader.java
@@ -57,7 +57,8 @@ import static org.apache.inlong.agent.constant.JobConstants.JOB_FILE_MAX_WAIT;
 import static org.apache.inlong.agent.constant.JobConstants.JOB_INSTANCE_ID;
 
 @RunWith(PowerMockRunner.class)
-@PowerMockIgnore({"javax.management.*", "javax.script.*"})
+@PowerMockIgnore({"javax.management.*", "javax.script.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*",
+        "org.w3c.*"})
 @PrepareForTest({MetricRegister.class})
 public class TestTextFileReader {
 
diff --git a/inlong-agent/agent-plugins/src/test/resources/log4j2.xml b/inlong-agent/agent-plugins/src/test/resources/log4j2.xml
new file mode 100644
index 000000000..32da5e4eb
--- /dev/null
+++ b/inlong-agent/agent-plugins/src/test/resources/log4j2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<configuration status="WARN" monitorInterval="30">
+    <Properties>
+        <property name="basePath">logs/plugins</property>
+        <property name="log_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} -%5p ${PID:-} [%15.15t] %-30.30C{1.} : %m%n</property>
+        <property name="output_log_level">DEBUG</property>
+        <property name="debug_fileName">${basePath}/ut-debug.log</property>
+        <property name="console_print_level">DEBUG</property>
+    </Properties>
+
+    <appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+            <ThresholdFilter level="${console_print_level}" onMatch="ACCEPT" onMismatch="DENY"/>
+            <PatternLayout pattern="${log_pattern}"/>
+        </Console>
+        <File name="File" fileName="${debug_fileName}">
+            <PatternLayout pattern="${log_pattern}"/>
+        </File>
+    </appenders>
+
+    <loggers>
+        <root level="${output_log_level}">
+            <appender-ref ref="Console"/>
+            <appender-ref ref="DebugFile"/>
+        </root>
+    </loggers>
+</configuration>
\ No newline at end of file