This is an automated email from the ASF dual-hosted git repository. sanjeevrk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push: new 75d9fe2 Logs should be output to stdout when running functions in Kubernetes (#2817) 75d9fe2 is described below commit 75d9fe2eeed76e7e085757e3facf0ee3db54959e Author: Boyang Jerry Peng <jerry.boyang.p...@gmail.com> AuthorDate: Mon Oct 22 19:07:29 2018 -0500 Logs should be output to stdout when running functions in Kubernetes (#2817) * Logs should be ouputted to stdout when running functions in Kubernetes * fix unittest * adding space --- .../functions/runtime/KubernetesRuntime.java | 2 +- .../main/resources/kubernetes_instance_log4j2.yml | 53 ++++++++++++++++++++++ .../functions/runtime/KubernetesRuntimeTest.java | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java index 40ef003..7a11111 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java @@ -129,7 +129,7 @@ class KubernetesRuntime implements Runtime { this.originalCodeFileName = pulsarRootDir + "/" + originalCodeFileName; this.pulsarAdminUrl = pulsarAdminUrl; this.processArgs = RuntimeUtils.composeArgs(instanceConfig, instanceFile, logDirectory, this.originalCodeFileName, pulsarServiceUrl, stateStorageServiceUrl, - authConfig, "$" + ENV_SHARD_ID, GRPC_PORT, -1l, pulsarRootDir + "/conf/log4j2.yaml", installUserCodeDependencies); + authConfig, "$" + ENV_SHARD_ID, GRPC_PORT, -1l, "kubernetes_instance_log4j2.yml", installUserCodeDependencies); this.prometheusMetricsServerArgs = composePrometheusMetricsServerArgs(prometheusMetricsServerJarFile, expectedMetricsInterval); running = false; doChecks(instanceConfig.getFunctionDetails()); diff --git a/pulsar-functions/runtime/src/main/resources/kubernetes_instance_log4j2.yml b/pulsar-functions/runtime/src/main/resources/kubernetes_instance_log4j2.yml new file mode 100644 index 0000000..98ce897 --- /dev/null +++ b/pulsar-functions/runtime/src/main/resources/kubernetes_instance_log4j2.yml @@ -0,0 +1,53 @@ +# +# 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: + name: pulsar-functions-kubernetes-instance + monitorInterval: 30 + + Properties: + Property: + - name: "pulsar.log.level" + value: "info" + - name: "bk.log.level" + value: "info" + + Appenders: + + # Console + Console: + name: Console + target: SYSTEM_OUT + PatternLayout: + Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" + + Loggers: + + Logger: + name: org.apache.pulsar.functions.runtime.shaded.org.apache.bookkeeper + level: "${sys:bk.log.level}" + additivity: false + AppenderRef: + - ref: Console + + Root: + level: info + AppenderRef: + - ref: Console + level: "${sys:pulsar.log.level}" diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java index 895a1e8..61cacca 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java @@ -124,7 +124,7 @@ public class KubernetesRuntimeTest { assertEquals(args.size(), 28); String expectedArgs = "java -cp " + javaInstanceJarFile + " -Dpulsar.functions.java.instance.jar=" + javaInstanceJarFile - + " -Dlog4j.configurationFile=/pulsar/conf/log4j2.yaml " + + " -Dlog4j.configurationFile=kubernetes_instance_log4j2.yml " + "-Dpulsar.function.log.dir=" + logDirectory + "/" + FunctionDetailsUtils.getFullyQualifiedName(config.getFunctionDetails()) + " -Dpulsar.function.log.file=" + config.getFunctionDetails().getName() + "-$SHARD_ID" + " org.apache.pulsar.functions.runtime.JavaInstanceMain"