You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/06/01 01:18:14 UTC

[incubator-servicecomb-java-chassis] branch master updated: [SCB-502] add a sample how to use log4j2 as log implement (#735)

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

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new d44a423  [SCB-502] add a sample how to use log4j2 as log implement (#735)
d44a423 is described below

commit d44a423dd53be5044c12f153f951fe197b176d8f
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Fri Jun 1 09:18:05 2018 +0800

    [SCB-502] add a sample how to use log4j2 as log implement (#735)
---
 java-chassis-dependencies/pom.xml                  |   5 +
 .../bmi/calculator/src/main/resources/log4j2.xml   | 227 ---------------------
 samples/pom.xml                                    |   1 +
 samples/use-log4j2-sample/pom.xml                  |  83 ++++++++
 .../servicecomb/samples/uselog4j2/Application.java |  26 +++
 .../servicecomb/samples/uselog4j2/Hello.java       |  22 ++
 .../servicecomb/samples/uselog4j2/HelloImpl.java   |  28 +++
 .../src/main/resources/log4j2.xml                  |  43 ++++
 .../src/main/resources/microservice.yaml           |  28 +++
 9 files changed, 236 insertions(+), 227 deletions(-)

diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml
index e303cce..c1e3955 100644
--- a/java-chassis-dependencies/pom.xml
+++ b/java-chassis-dependencies/pom.xml
@@ -552,6 +552,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-slf4j-impl</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-api</artifactId>
         <version>${log4j2.version}</version>
       </dependency>
diff --git a/samples/bmi/calculator/src/main/resources/log4j2.xml b/samples/bmi/calculator/src/main/resources/log4j2.xml
deleted file mode 100644
index a5ba7b3..0000000
--- a/samples/bmi/calculator/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,227 +0,0 @@
-<?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="error" monitorInterval="300">
-  <Properties>
-    <!--metrics文件Rolling单文件最大大小(KB,MB,GB)-->
-    <Property name="maxFileSize">10MB</Property>
-    <!--metrics文件Rolling保存数量-->
-    <Property name="maxFileCount">10</Property>
-    <!--metrics文件存储目录-->
-    <Property name="filePath">./samples/bmi/calculator/target/metric/</Property>
-    <!--metrics文件名前缀-->
-    <Property name="filePrefix">bmi.calculator</Property>
-  </Properties>
-
-  <Appenders>
-    <RollingFile name="averageServiceExecutionTime" fileName="${filePath}${filePrefix}.averageServiceExecutionTime.dat"
-      filePattern="${filePath}${filePrefix}.averageServiceExecutionTime-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="averageTimeInQueue" fileName="${filePath}${filePrefix}.averageTimeInQueue.dat"
-      filePattern="${filePath}${filePrefix}.averageTimeInQueue-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="countInQueue" fileName="${filePath}${filePrefix}.countInQueue.dat"
-      filePattern="${filePath}${filePrefix}.countInQueue-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="cpuLoad" fileName="${filePath}${filePrefix}.cpuLoad.dat"
-      filePattern="${filePath}${filePrefix}.cpuLoad-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="cpuRunningThreads" fileName="${filePath}${filePrefix}.cpuRunningThreads.dat"
-      filePattern="${filePath}${filePrefix}.cpuRunningThreads-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="heapCommit" fileName="${filePath}${filePrefix}.heapCommit.dat"
-      filePattern="${filePath}${filePrefix}.heapCommit-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="heapInit" fileName="${filePath}${filePrefix}.heapInit.dat"
-      filePattern="${filePath}${filePrefix}.heapInit-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="heapMax" fileName="${filePath}${filePrefix}.heapMax.dat"
-      filePattern="${filePath}${filePrefix}.heapMax-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="heapUsed" fileName="${filePath}${filePrefix}.heapUsed.dat"
-      filePattern="${filePath}${filePrefix}.heapUsed-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="latency" fileName="${filePath}${filePrefix}.latency.dat"
-      filePattern="${filePath}${filePrefix}.latency-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="maxLifeTimeInQueue" fileName="${filePath}${filePrefix}.maxLifeTimeInQueue.dat"
-      filePattern="${filePath}${filePrefix}.maxLifeTimeInQueue-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="minLifeTimeInQueue" fileName="${filePath}${filePrefix}.minLifeTimeInQueue.dat"
-      filePattern="${filePath}${filePrefix}.minLifeTimeInQueue-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="nonHeapCommit" fileName="${filePath}${filePrefix}.nonHeapCommit.dat"
-      filePattern="${filePath}${filePrefix}.nonHeapCommit-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="nonHeapInit" fileName="${filePath}${filePrefix}.nonHeapInit.dat"
-      filePattern="${filePath}${filePrefix}.nonHeapInit-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="nonHeapMax" fileName="${filePath}${filePrefix}.nonHeapMax.dat"
-      filePattern="${filePath}${filePrefix}.nonHeapMax-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="nonHeapUsed" fileName="${filePath}${filePrefix}.nonHeapUsed.dat"
-      filePattern="${filePath}${filePrefix}.nonHeapUsed-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="totalFailedRequestsPerProvider"
-      fileName="${filePath}${filePrefix}.totalFailedRequestsPerProvider.dat"
-      filePattern="${filePath}${filePrefix}.totalFailedRequestsPerProvider-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="totalFailRequestsPerConsumer"
-      fileName="${filePath}${filePrefix}.totalFailRequestsPerConsumer.dat"
-      filePattern="${filePath}${filePrefix}.totalFailRequestsPerConsumer-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="totalRequestsPerConsumer" fileName="${filePath}${filePrefix}.totalRequestsPerConsumer.dat"
-      filePattern="${filePath}${filePrefix}.totalRequestsPerConsumer-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="totalRequestsPerProvider" fileName="${filePath}${filePrefix}.totalRequestsPerProvider.dat"
-      filePattern="${filePath}${filePrefix}.totalRequestsPerProvider-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-    <RollingFile name="tps" fileName="${filePath}${filePrefix}.tps.dat"
-      filePattern="${filePath}${filePrefix}.tps-%i.dat">
-      <PatternLayout pattern="%m%n"/>
-      <SizeBasedTriggeringPolicy size="${maxFileSize}"/>
-      <DefaultRolloverStrategy max="${maxFileCount}"/>
-    </RollingFile>
-  </Appenders>
-
-  <Loggers>
-    <Logger name="averageServiceExecutionTime" level="trace" additivity="false">
-      <AppenderRef ref="averageServiceExecutionTime"/>
-    </Logger>
-    <Logger name="averageTimeInQueue" level="trace" additivity="false">
-      <AppenderRef ref="averageTimeInQueue"/>
-    </Logger>
-    <Logger name="countInQueue" level="trace" additivity="false">
-      <AppenderRef ref="countInQueue"/>
-    </Logger>
-    <Logger name="cpuLoad" level="trace" additivity="false">
-      <AppenderRef ref="cpuLoad"/>
-    </Logger>
-    <Logger name="cpuRunningThreads" level="trace" additivity="false">
-      <AppenderRef ref="cpuRunningThreads"/>
-    </Logger>
-    <Logger name="heapCommit" level="trace" additivity="false">
-      <AppenderRef ref="heapCommit"/>
-    </Logger>
-    <Logger name="heapInit" level="trace" additivity="false">
-      <AppenderRef ref="heapInit"/>
-    </Logger>
-    <Logger name="heapMax" level="trace" additivity="false">
-      <AppenderRef ref="heapMax"/>
-    </Logger>
-    <Logger name="heapUsed" level="trace" additivity="false">
-      <AppenderRef ref="heapUsed"/>
-    </Logger>
-    <Logger name="latency" level="trace" additivity="false">
-      <AppenderRef ref="latency"/>
-    </Logger>
-    <Logger name="maxLifeTimeInQueue" level="trace" additivity="false">
-      <AppenderRef ref="maxLifeTimeInQueue"/>
-    </Logger>
-    <Logger name="minLifeTimeInQueue" level="trace" additivity="false">
-      <AppenderRef ref="minLifeTimeInQueue"/>
-    </Logger>
-    <Logger name="nonHeapCommit" level="trace" additivity="false">
-      <AppenderRef ref="nonHeapCommit"/>
-    </Logger>
-    <Logger name="nonHeapInit" level="trace" additivity="false">
-      <AppenderRef ref="nonHeapInit"/>
-    </Logger>
-    <Logger name="nonHeapMax" level="trace" additivity="false">
-      <AppenderRef ref="nonHeapMax"/>
-    </Logger>
-    <Logger name="nonHeapUsed" level="trace" additivity="false">
-      <AppenderRef ref="nonHeapUsed"/>
-    </Logger>
-    <Logger name="totalFailedRequestsPerProvider" level="trace" additivity="false">
-      <AppenderRef ref="totalFailedRequestsPerProvider"/>
-    </Logger>
-    <Logger name="totalFailRequestsPerConsumer" level="trace" additivity="false">
-      <AppenderRef ref="totalFailRequestsPerConsumer"/>
-    </Logger>
-    <Logger name="totalRequestsPerConsumer" level="trace" additivity="false">
-      <AppenderRef ref="totalRequestsPerConsumer"/>
-    </Logger>
-    <Logger name="totalRequestsPerProvider" level="trace" additivity="false">
-      <AppenderRef ref="totalRequestsPerProvider"/>
-    </Logger>
-    <Logger name="tps" level="trace" additivity="false">
-      <AppenderRef ref="tps"/>
-    </Logger>
-  </Loggers>
-</configuration>
\ No newline at end of file
diff --git a/samples/pom.xml b/samples/pom.xml
index b724869..4acbd03 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -37,6 +37,7 @@
     <module>metrics-write-file-sample</module>
     <module>metrics-extend-healthcheck</module>
     <module>config-apollo-sample</module>
+    <module>use-log4j2-sample</module>
   </modules>
 
   <dependencyManagement>
diff --git a/samples/use-log4j2-sample/pom.xml b/samples/use-log4j2-sample/pom.xml
new file mode 100644
index 0000000..7801272
--- /dev/null
+++ b/samples/use-log4j2-sample/pom.xml
@@ -0,0 +1,83 @@
+<?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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>samples</artifactId>
+    <groupId>org.apache.servicecomb.samples</groupId>
+    <version>1.0.0-m2-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>use-log4j2-sample</artifactId>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    <java.version>1.8</java.version>
+    <java-chassis.version>${project.version}</java-chassis.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>${java-chassis.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-rest-vertx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-highway</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>provider-pojo</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/Application.java b/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/Application.java
new file mode 100644
index 0000000..af2e674
--- /dev/null
+++ b/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/Application.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package org.apache.servicecomb.samples.uselog4j2;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class Application {
+  public static void main(String[] args) {
+    BeanUtils.init();
+  }
+}
\ No newline at end of file
diff --git a/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/Hello.java b/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/Hello.java
new file mode 100644
index 0000000..5b35784
--- /dev/null
+++ b/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/Hello.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+package org.apache.servicecomb.samples.uselog4j2;
+
+public interface Hello {
+  String hello();
+}
\ No newline at end of file
diff --git a/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/HelloImpl.java b/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/HelloImpl.java
new file mode 100644
index 0000000..1c9d9e4
--- /dev/null
+++ b/samples/use-log4j2-sample/src/main/java/org/apache/servicecomb/samples/uselog4j2/HelloImpl.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package org.apache.servicecomb.samples.uselog4j2;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+
+@RpcSchema(schemaId = "hello")
+public class HelloImpl implements Hello {
+
+  public String hello() {
+    return "Hello World!";
+  }
+}
\ No newline at end of file
diff --git a/samples/use-log4j2-sample/src/main/resources/log4j2.xml b/samples/use-log4j2-sample/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..0651a7b
--- /dev/null
+++ b/samples/use-log4j2-sample/src/main/resources/log4j2.xml
@@ -0,0 +1,43 @@
+<?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.
+  -->
+
+<!--this is sample configuration, please modify as your wish-->
+
+<configuration>
+  <Properties>
+    <Property name="log_path">./samples/use-log4j2-sample/target/log/</Property>
+  </Properties>
+
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+    </Console>
+    <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log"
+      filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log">
+      <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/>
+      <TimeBasedTriggeringPolicy interval="1"/>
+      <SizeBasedTriggeringPolicy size="10 MB"/>
+    </RollingFile>
+  </Appenders>
+  <Loggers>
+    <Root level="info">
+      <AppenderRef ref="Console"/>
+      <AppenderRef ref="DailyRollingFile"/>
+    </Root>
+  </Loggers>
+</configuration>
\ No newline at end of file
diff --git a/samples/use-log4j2-sample/src/main/resources/microservice.yaml b/samples/use-log4j2-sample/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..3147b3e
--- /dev/null
+++ b/samples/use-log4j2-sample/src/main/resources/microservice.yaml
@@ -0,0 +1,28 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+APPLICATION_ID: samples
+service_description:
+  name: uselog4j2
+  version: 0.0.1
+servicecomb:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  rest:
+    address: 0.0.0.0:8080
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.