You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@servicecomb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/01 01:19:00 UTC

[jira] [Commented] (SCB-502) logs日志没有输出

    [ https://issues.apache.org/jira/browse/SCB-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497446#comment-16497446 ] 

ASF GitHub Bot commented on SCB-502:
------------------------------------

WillemJiang closed pull request #735: [SCB-502] add a sample how to use log4j2 as log implement
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/735
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml
index e303cce34..c1e3955b0 100644
--- a/java-chassis-dependencies/pom.xml
+++ b/java-chassis-dependencies/pom.xml
@@ -550,6 +550,11 @@
         <artifactId>log4j</artifactId>
         <version>${log4j.version}</version>
       </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>
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 a5ba7b3f0..000000000
--- 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 b724869b2..4acbd031e 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 000000000..780127205
--- /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 000000000..af2e67453
--- /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 000000000..5b35784a0
--- /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 000000000..1c9d9e4e4
--- /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 000000000..0651a7b5d
--- /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 000000000..3147b3e68
--- /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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> logs日志没有输出
> ----------
>
>                 Key: SCB-502
>                 URL: https://issues.apache.org/jira/browse/SCB-502
>             Project: Apache ServiceComb
>          Issue Type: Bug
>          Components: Java-Chassis
>    Affects Versions: java-chassis-1.0.0-m1
>            Reporter: miaoyanjie
>            Assignee: yangyongzheng
>            Priority: Major
>              Labels: log4j, log4j2, servicecomb
>             Fix For: java-chassis-1.0.0-m2
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 急急急
> 我项目是以springboot为基础构建的,用Log4j2输出日志成功。
> 加上servicecomb之后,日志没有输出。
> 并且incubator-servicecomb-java-chassis/samples/bmi的日志也没有输出成功。
> 希望给出解决方案。



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)