Repository: samza Updated Branches: refs/heads/master 07199cb07 -> 1e880ea63
http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/TestStreamAppender.java ---------------------------------------------------------------------- diff --git a/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/TestStreamAppender.java b/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/TestStreamAppender.java new file mode 100644 index 0000000..280f54e --- /dev/null +++ b/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/TestStreamAppender.java @@ -0,0 +1,298 @@ +/* + * 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.samza.logging.log4j2; + +import static org.junit.Assert.*; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.layout.PatternLayout; +import org.apache.samza.config.MapConfig; +import org.apache.samza.logging.log4j2.serializers.LoggingEventJsonSerde; +import org.apache.samza.logging.log4j2.serializers.LoggingEventStringSerde; +import org.apache.samza.logging.log4j2.serializers.LoggingEventStringSerdeFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; + +public class TestStreamAppender { + + static Logger log = (Logger) LogManager.getLogger(TestStreamAppender.class); + + @After + public void tearDown() { + removeAllAppenders(); + MockSystemProducer.listeners.clear(); + MockSystemProducer.messagesReceived.clear(); + MockSystemAdmin.createdStreamName = ""; + } + + @Test + public void testDefaultSerde() { + System.setProperty("samza.container.name", "samza-container-1"); + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.start(); + assertNotNull(systemProducerAppender.getSerde()); + assertEquals(LoggingEventJsonSerde.class, systemProducerAppender.getSerde().getClass()); + } + + @Test + public void testNonDefaultSerde() { + System.setProperty("samza.container.name", "samza-container-1"); + String streamName = StreamAppender.getStreamName("log4jTest", "1"); + Map<String, String> map = new HashMap<String, String>(); + map.put("job.name", "log4jTest"); + map.put("job.id", "1"); + map.put("serializers.registry.log4j-string.class", LoggingEventStringSerdeFactory.class.getCanonicalName()); + map.put("systems.mock.samza.factory", MockSystemFactory.class.getCanonicalName()); + map.put("systems.mock.streams." + streamName + ".samza.msg.serde", "log4j-string"); + map.put("task.log4j.system", "mock"); + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, new MapConfig(map), null); + systemProducerAppender.start(); + assertNotNull(systemProducerAppender.getSerde()); + assertEquals(LoggingEventStringSerde.class, systemProducerAppender.getSerde().getClass()); + } + + @Test + public void testDefaultStreamName() { + System.setProperty("samza.container.name", "samza-container-1"); + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + Assert.assertEquals("__samza_log4jTest_1_logs", systemProducerAppender.getStreamName()); + } + + @Test + public void testCustomStreamName() { + System.setProperty("samza.container.name", "samza-container-1"); + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, "test-stream-name"); + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + Assert.assertEquals("test-stream-name", systemProducerAppender.getStreamName()); + } + + @Test + public void testSystemProducerAppenderInContainer() throws InterruptedException { + System.setProperty("samza.container.name", "samza-container-1"); + + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.start(); + + log.addAppender(systemProducerAppender); + log.setLevel(Level.INFO); + List<String> messages = Lists.newArrayList("testing1", "testing2"); + logAndVerifyMessages(messages); + systemProducerAppender.stop(); + } + + @Test + public void testSystemProducerAppenderInAM() throws InterruptedException { + System.setProperty("samza.container.name", "samza-job-coordinator"); + + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + log.setLevel(Level.INFO); + + log.info("no-received"); // System isn't initialized yet, so this message should be dropped + + systemProducerAppender.setupSystem(); + MockSystemProducerAppender.systemInitialized = true; + + List<String> messages = Lists.newArrayList("testing3", "testing4"); + logAndVerifyMessages(messages); + systemProducerAppender.stop(); + } + + @Test + public void testNoStreamCreationUponSetupByDefault() { + System.setProperty("samza.container.name", "samza-container-1"); + + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + + Assert.assertEquals("", MockSystemAdmin.createdStreamName); + } + + @Test + public void testStreamCreationUponSetupWhenEnabled() { + System.setProperty("samza.container.name", "samza-container-1"); + + MapConfig mapConfig = new MapConfig(ImmutableMap.of( + "task.log4j.create.stream.enabled", "true", // Enable explicit stream creation + "job.name", "log4jTest", + "job.id", "1", + "systems.mock.samza.factory", MockSystemFactory.class.getCanonicalName(), + "task.log4j.system", "mock")); + + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, mapConfig, null); + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + + Assert.assertEquals("__samza_log4jTest_1_logs", MockSystemAdmin.createdStreamName); + } + + @Test + public void testDefaultPartitionCount() { + System.setProperty("samza.container.name", "samza-container-1"); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, null, false, null, null); + Assert.assertEquals(1, systemProducerAppender.getPartitionCount()); // job.container.count defaults to 1 + + Map<String, String> map = new HashMap<>(); + map.put("job.name", "log4jTest"); + map.put("job.id", "1"); + map.put("systems.mock.samza.factory", MockSystemFactory.class.getCanonicalName()); + map.put("task.log4j.system", "mock"); + map.put("job.container.count", "4"); + systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, null, false, new MapConfig(map), null); + Assert.assertEquals(4, systemProducerAppender.getPartitionCount()); + + systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, null, false, null, null); + systemProducerAppender.setPartitionCount(8); + Assert.assertEquals(8, systemProducerAppender.getPartitionCount()); + } + + @Test + public void testExceptionsDoNotKillTransferThread() throws InterruptedException { + System.setProperty("samza.container.name", "samza-container-1"); + + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + log.setLevel(Level.INFO); + + List<String> messages = Lists.newArrayList("testing5", "testing6", "testing7"); + + // Set up latch + final CountDownLatch allMessagesSent = new CountDownLatch(messages.size()); + MockSystemProducer.listeners.add((source, envelope) -> { + allMessagesSent.countDown(); + if (allMessagesSent.getCount() == messages.size() - 1) { + throw new RuntimeException(); // Throw on the first message + } + }); + + // Log the messages + messages.forEach((message) -> log.info(message)); + + // Wait for messages + assertTrue("Thread did not send all messages. Count: " + allMessagesSent.getCount(), + allMessagesSent.await(60, TimeUnit.SECONDS)); + systemProducerAppender.stop(); + } + + @Test + public void testQueueTimeout() throws InterruptedException { + System.setProperty("samza.container.name", "samza-container-1"); + + PatternLayout layout = PatternLayout.newBuilder().withPattern("%m").build(); + MockSystemProducerAppender systemProducerAppender = MockSystemProducerAppender.createAppender("testName", null, layout, false, null, null); + systemProducerAppender.queueTimeoutS = 1; + systemProducerAppender.start(); + log.addAppender(systemProducerAppender); + log.setLevel(Level.INFO); + + int extraMessageCount = 5; + int expectedMessagesSent = extraMessageCount - 1; // -1 because when the queue is drained there is one additional message that couldn't be added + List<String> messages = new ArrayList<>(StreamAppender.DEFAULT_QUEUE_SIZE + extraMessageCount); + for (int i = 0; i < StreamAppender.DEFAULT_QUEUE_SIZE + extraMessageCount; i++) { + messages.add(String.valueOf(i)); + } + + // Set up latch + final CountDownLatch allMessagesSent = new CountDownLatch(expectedMessagesSent); // We expect to drop all but the extra messages + final CountDownLatch waitForTimeout = new CountDownLatch(1); + MockSystemProducer.listeners.add((source, envelope) -> { + allMessagesSent.countDown(); + try { + waitForTimeout.await(); + } catch (InterruptedException e) { + fail("Test could not run properly because of a thread interrupt."); + } + }); + + // Log the messages. This is where the timeout will happen! + messages.forEach((message) -> log.info(message)); + + assertEquals(messages.size() - expectedMessagesSent, systemProducerAppender.metrics.logMessagesDropped.getCount()); + + // Allow all the rest of the messages to send. + waitForTimeout.countDown(); + + // Wait for messages + assertTrue("Thread did not send all messages. Count: " + allMessagesSent.getCount(), + allMessagesSent.await(60, TimeUnit.SECONDS)); + assertEquals(expectedMessagesSent, MockSystemProducer.messagesReceived.size()); + systemProducerAppender.stop(); + } + + private void logAndVerifyMessages(List<String> messages) throws InterruptedException { + // Set up latch + final CountDownLatch allMessagesSent = new CountDownLatch(messages.size()); + MockSystemProducer.listeners.add((source, envelope) -> allMessagesSent.countDown()); + + // Log the messages + messages.forEach((message) -> log.info(message)); + + // Wait for messages + assertTrue("Timeout while waiting for StreamAppender to send all messages. Count: " + allMessagesSent.getCount(), + allMessagesSent.await(60, TimeUnit.SECONDS)); + + // Verify + assertEquals(messages.size(), MockSystemProducer.messagesReceived.size()); + for (int i = 0; i < messages.size(); i++) { + HashMap<String, String> messageMap = new HashMap<String, String>(); + assertTrue("Message mismatch at index " + i, + new String((byte[]) MockSystemProducer.messagesReceived.get(i)).contains(asJsonMessageSegment(messages.get(i)))); + } + } + + private String asJsonMessageSegment(String message) { + return String.format("\"formatted-message\":\"%s\"", message); + } + + private void removeAllAppenders() { + Map<String, Appender> allAppenders = log.getAppenders(); + for (String name: allAppenders.keySet()) { + log.removeAppender(allAppenders.get(name)); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/serializers/TestLoggingEventStringSerde.java ---------------------------------------------------------------------- diff --git a/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/serializers/TestLoggingEventStringSerde.java b/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/serializers/TestLoggingEventStringSerde.java new file mode 100644 index 0000000..e392bb8 --- /dev/null +++ b/samza-log4j2/src/test/java/org/apache/samza/logging/log4j2/serializers/TestLoggingEventStringSerde.java @@ -0,0 +1,52 @@ +/* + * 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.samza.logging.log4j2.serializers; + +import static org.junit.Assert.*; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.impl.Log4jLogEvent; +import org.apache.logging.log4j.message.SimpleMessage; +import org.junit.Test; + +public class TestLoggingEventStringSerde { + + @Test + public void test() { + String testLog = "testing"; + Logger logger = (Logger) LogManager.getLogger(TestLoggingEventStringSerde.class); + LogEvent log = Log4jLogEvent.newBuilder() + .setLevel(logger.getLevel()) + .setLoggerName(logger.getName()) + .setMessage(new SimpleMessage(testLog)) + .setThrown(null) + .build(); + LoggingEventStringSerde loggingEventStringSerde = new LoggingEventStringSerde(); + + assertNull(loggingEventStringSerde.fromBytes(null)); + assertNull(loggingEventStringSerde.toBytes(null)); + + assertArrayEquals(testLog.getBytes(), loggingEventStringSerde.toBytes(log)); + // only the log messages are guaranteed to be equivalent + assertEquals(log.getMessage().toString(), loggingEventStringSerde.fromBytes(testLog.getBytes()).getMessage().toString()); + } +} http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-log4j2/src/test/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/samza-log4j2/src/test/resources/log4j2.xml b/samza-log4j2/src/test/resources/log4j2.xml new file mode 100644 index 0000000..578dd5f --- /dev/null +++ b/samza-log4j2/src/test/resources/log4j2.xml @@ -0,0 +1,37 @@ +<?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 packages="org.apache.samza.logging.log4j2"> + <Appenders> + + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} [%p] %m%n"/> + </Console> + + </Appenders> + + <Loggers> + + <Logger name="STARTUP_LOGGER" level="info" additivity="false"> + <AppenderRef ref="STDOUT"/> + </Logger> + + <Logger name="org.apache.hadoop" level="off"></Logger> + + <Root level="info"> + <AppenderRef ref="STDOUT"/> + <AppenderRef ref="JmxAppender"/> + </Root> + + </Loggers> +</Configuration> http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-rest/src/main/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/samza-rest/src/main/resources/log4j2.xml b/samza-rest/src/main/resources/log4j2.xml new file mode 100644 index 0000000..fdded6f --- /dev/null +++ b/samza-rest/src/main/resources/log4j2.xml @@ -0,0 +1,40 @@ +<?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> + <Appenders> + <RollingFile name="RollingFile" fileName="${sys:samza.log.dir}/samza-rest-service.log.log" + filePattern="${sys:samza.log.dir}/samza-rest-service-%d{MM-dd-yyyy}-%i.log.gz"> + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} [%p] %m%n"/> + <Policies> + <SizeBasedTriggeringPolicy size="256MB" /> + </Policies> + <DefaultRolloverStrategy max="20"/> + </RollingFile> + </Appenders> + + <Loggers> + <Logger name="org.apache.hadoop" level="off"></Logger> + <Root level="info"> + <AppenderRef ref="RollingFile"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/checkpoint-tool.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/checkpoint-tool.sh b/samza-shell/src/main/bash/checkpoint-tool.sh index d32f9ce..12e7584 100755 --- a/samza-shell/src/main/bash/checkpoint-tool.sh +++ b/samza-shell/src/main/bash/checkpoint-tool.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.checkpoint.CheckpointTool "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/kill-all.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/kill-all.sh b/samza-shell/src/main/bash/kill-all.sh index da230a4..d69127a 100755 --- a/samza-shell/src/main/bash/kill-all.sh +++ b/samza-shell/src/main/bash/kill-all.sh @@ -16,9 +16,13 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi -exec $(dirname $0)/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -list | grep application_ | awk -F ' ' '{ print $1 }' | while read linea +exec $(dirname $0)/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -list | grep application_ | awk -F ' ' '{ print $1 }' | while read linea do $(dirname $0)/kill-yarn-job.sh $linea done http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/kill-yarn-job-by-name.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/kill-yarn-job-by-name.sh b/samza-shell/src/main/bash/kill-yarn-job-by-name.sh index 06eacc7..81968ac 100755 --- a/samza-shell/src/main/bash/kill-yarn-job-by-name.sh +++ b/samza-shell/src/main/bash/kill-yarn-job-by-name.sh @@ -15,7 +15,12 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" + +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi # Get the id for the app with the specified name that is also ACCEPTED or RUNNING status APP_ID=$(exec "$(dirname $0)"/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -list | grep "[[:space:]]$1[[:space:]]" | grep "application_" | awk -F ' ' '{ print $1 }') http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/kill-yarn-job.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/kill-yarn-job.sh b/samza-shell/src/main/bash/kill-yarn-job.sh index 4d322f8..f21e466 100755 --- a/samza-shell/src/main/bash/kill-yarn-job.sh +++ b/samza-shell/src/main/bash/kill-yarn-job.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -kill "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/list-yarn-job.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/list-yarn-job.sh b/samza-shell/src/main/bash/list-yarn-job.sh index 10cdb44..6579189 100755 --- a/samza-shell/src/main/bash/list-yarn-job.sh +++ b/samza-shell/src/main/bash/list-yarn-job.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -list http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/read-rocksdb-tool.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/read-rocksdb-tool.sh b/samza-shell/src/main/bash/read-rocksdb-tool.sh index c4565c5..85d0af9 100755 --- a/samza-shell/src/main/bash/read-rocksdb-tool.sh +++ b/samza-shell/src/main/bash/read-rocksdb-tool.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.storage.kv.RocksDbReadingTool "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/run-app.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/run-app.sh b/samza-shell/src/main/bash/run-app.sh index 3880e3c..9a7ae2d 100755 --- a/samza-shell/src/main/bash/run-app.sh +++ b/samza-shell/src/main/bash/run-app.sh @@ -25,6 +25,10 @@ cd $home_dir export EXECUTION_PLAN_DIR="$base_dir/plan" mkdir -p $EXECUTION_PLAN_DIR -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.runtime.ApplicationRunnerMain "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/run-class.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/run-class.sh b/samza-shell/src/main/bash/run-class.sh index ee9eb31..440dbdc 100755 --- a/samza-shell/src/main/bash/run-class.sh +++ b/samza-shell/src/main/bash/run-class.sh @@ -41,6 +41,7 @@ HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_YARN_HOME/conf}" CLASSPATH=$HADOOP_CONF_DIR GC_LOG_ROTATION_OPTS="-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10241024" DEFAULT_LOG4J_FILE=$base_dir/lib/log4j.xml +DEFAULT_LOG4J2_FILE=$base_dir/lib/log4j2.xml BASE_LIB_DIR="$base_dir/lib" # JOB_LIB_DIR will be set for yarn container in ContainerUtil.java # for others we set it to home_dir/lib @@ -113,8 +114,15 @@ function check_and_enable_64_bit_mode { ### Inherit JVM_OPTS from task.opts configuration, and initialize defaults ### +# Make the MDC inheritable to child threads by setting the system property to true if config not explicitly specified +[[ $JAVA_OPTS != *-DisThreadContextMapInheritable* ]] && JAVA_OPTS="$JAVA_OPTS -DisThreadContextMapInheritable=true" + # Check if log4j configuration is specified. If not - set to lib/log4j.xml -[[ $JAVA_OPTS != *-Dlog4j.configuration* && -f $DEFAULT_LOG4J_FILE ]] && JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$DEFAULT_LOG4J_FILE" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$DEFAULT_LOG4J2_FILE" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$DEFAULT_LOG4J_FILE" +fi # Check if samza.log.dir is specified. If not - set to environment variable if it is set [[ $JAVA_OPTS != *-Dsamza.log.dir* && ! -z "$SAMZA_LOG_DIR" ]] && JAVA_OPTS="$JAVA_OPTS -Dsamza.log.dir=$SAMZA_LOG_DIR" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/run-config-manager.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/run-config-manager.sh b/samza-shell/src/main/bash/run-config-manager.sh index 2de68ed..96777e7 100755 --- a/samza-shell/src/main/bash/run-config-manager.sh +++ b/samza-shell/src/main/bash/run-config-manager.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.autoscaling.deployer.ConfigManager "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/run-coordinator-stream-writer.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/run-coordinator-stream-writer.sh b/samza-shell/src/main/bash/run-coordinator-stream-writer.sh index d2249dd..6f6d99f 100755 --- a/samza-shell/src/main/bash/run-coordinator-stream-writer.sh +++ b/samza-shell/src/main/bash/run-coordinator-stream-writer.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.coordinator.stream.CoordinatorStreamWriter "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/run-job.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/run-job.sh b/samza-shell/src/main/bash/run-job.sh index b100ef6..554c69d 100755 --- a/samza-shell/src/main/bash/run-job.sh +++ b/samza-shell/src/main/bash/run-job.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.job.JobRunner "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/stat-yarn-job.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/stat-yarn-job.sh b/samza-shell/src/main/bash/stat-yarn-job.sh index e5f6847..ee61d10 100755 --- a/samza-shell/src/main/bash/stat-yarn-job.sh +++ b/samza-shell/src/main/bash/stat-yarn-job.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -status "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/state-storage-tool.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/state-storage-tool.sh b/samza-shell/src/main/bash/state-storage-tool.sh index 05a4f25..b7ac8b6 100755 --- a/samza-shell/src/main/bash/state-storage-tool.sh +++ b/samza-shell/src/main/bash/state-storage-tool.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.storage.StateStorageTool "$@" http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/bash/validate-yarn-job.sh ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/bash/validate-yarn-job.sh b/samza-shell/src/main/bash/validate-yarn-job.sh index 8273a32..d9c436c 100755 --- a/samza-shell/src/main/bash/validate-yarn-job.sh +++ b/samza-shell/src/main/bash/validate-yarn-job.sh @@ -16,6 +16,10 @@ # specific language governing permissions and limitations # under the License. -[[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +if [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j2.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configurationFile* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$(dirname $0)/log4j2-console.xml" +elif [[ -n $(find "$base_dir/lib" -regex ".*samza-log4j.*.jar*") ]]; then + [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml" +fi exec $(dirname $0)/run-class.sh org.apache.samza.validation.YarnJobValidationTool "$@" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-shell/src/main/resources/log4j2-console.xml ---------------------------------------------------------------------- diff --git a/samza-shell/src/main/resources/log4j2-console.xml b/samza-shell/src/main/resources/log4j2-console.xml new file mode 100644 index 0000000..f3dbd00 --- /dev/null +++ b/samza-shell/src/main/resources/log4j2-console.xml @@ -0,0 +1,35 @@ +<?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> + <Appenders> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} [%p] %m%n"/> + </Console> + </Appenders> + + <Loggers> + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-sql/src/test/resources/log4j.xml ---------------------------------------------------------------------- diff --git a/samza-sql/src/test/resources/log4j.xml b/samza-sql/src/test/resources/log4j.xml index 9d29506..a0eabd4 100644 --- a/samza-sql/src/test/resources/log4j.xml +++ b/samza-sql/src/test/resources/log4j.xml @@ -13,10 +13,6 @@ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> - @log4j.appenders.webapp@ - - @log4j.appenders.public_access@ - <appender name="console" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" @@ -24,21 +20,16 @@ </layout> </appender> - @log4j.loggers.spring@ - - @log4j.loggers.public_access@ <logger name="org.apache" additivity="false"> <level value="INFO"/> <appender-ref ref="console"/> </logger> - @log4j.loggers.public_access@ <logger name="org.apache.calcite.sql2rel" additivity="false"> <level value="DEBUG"/> <appender-ref ref="console"/> </logger> - @log4j.loggers.root@ <root> <priority value ="DEBUG" /> <appender-ref ref="console"/> http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-sql/src/test/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/samza-sql/src/test/resources/log4j2.xml b/samza-sql/src/test/resources/log4j2.xml new file mode 100644 index 0000000..8cbd4b9 --- /dev/null +++ b/samza-sql/src/test/resources/log4j2.xml @@ -0,0 +1,35 @@ +<?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> + + <Appenders> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/> + </Console> + </Appenders> + + <Loggers> + <Logger name="org.apache" level="info" additivity="false"> + <AppenderRef ref="STDOUT"/> + </Logger> + + <Logger name="org.apache.calcite.sql2rel" level="debug" additivity="false"> + <AppenderRef ref="STDOUT"/> + </Logger> + + <Root level="debug"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> + +</Configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-test/src/main/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/samza-test/src/main/resources/log4j2.xml b/samza-test/src/main/resources/log4j2.xml new file mode 100644 index 0000000..f00cb7d --- /dev/null +++ b/samza-test/src/main/resources/log4j2.xml @@ -0,0 +1,41 @@ +<?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> + <Appenders> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="[%t] %c{1} [%p] %m%n"/> + </Console> + </Appenders> + <Loggers> + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + + <Logger name="STARTUP_LOGGER" level="info" additivity="false"> + <AppenderRef ref="STDOUT"/> + </Logger> + + <Logger name="org.apache.hadoop" level="error"></Logger> + + <Logger name="org.I0Itec.zkclient" level="error"></Logger> + + <Logger name="org.apache.zookeeper" level="error"></Logger> + + <Logger name="org.apache.samza.system.kafka" level="error"></Logger> + + <Logger name="org.apache.kafka" level="error"></Logger> + + <Logger name="kafka" level="error"></Logger> + + </Loggers> +</Configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-tools/src/main/resources/log4j.xml ---------------------------------------------------------------------- diff --git a/samza-tools/src/main/resources/log4j.xml b/samza-tools/src/main/resources/log4j.xml index 15aad1c..edbf4ea 100644 --- a/samza-tools/src/main/resources/log4j.xml +++ b/samza-tools/src/main/resources/log4j.xml @@ -13,10 +13,6 @@ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> - @log4j.appenders.webapp@ - - @log4j.appenders.public_access@ - <appender name="console" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" @@ -24,20 +20,15 @@ </layout> </appender> - @log4j.loggers.spring@ - - @log4j.loggers.public_access@ <logger name="org.apache" additivity="false"> <level value="DEBUG"/> <appender-ref ref="console"/> </logger> - @log4j.loggers.root@ <root> <priority value ="info" /> <appender-ref ref="console"/> </root> - </log4j:configuration> http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/samza-tools/src/main/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/samza-tools/src/main/resources/log4j2.xml b/samza-tools/src/main/resources/log4j2.xml new file mode 100644 index 0000000..0331699 --- /dev/null +++ b/samza-tools/src/main/resources/log4j2.xml @@ -0,0 +1,32 @@ +<?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> + + <Appenders> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/> + </Console> + </Appenders> + + <Loggers> + <Logger name="org.apache" level="debug" additivity="false"> + <AppenderRef ref="STDOUT"/> + </Logger> + + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> + +</Configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/samza/blob/1e880ea6/settings.gradle ---------------------------------------------------------------------- diff --git a/settings.gradle b/settings.gradle index 99d27a0..853a7bb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,6 +23,7 @@ include \ 'samza-azure', 'samza-elasticsearch', 'samza-log4j', + 'samza-log4j2', 'samza-rest', 'samza-shell', 'samza-sql',