diff --git a/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java b/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
index e590678..c9239b1 100644
--- a/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
+++ b/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
@@ -55,7 +55,6 @@ import org.apache.log4j.FileAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.Logger;
import org.apache.log4j.RollingFileAppender;
-import org.json.simple.JSONObject;
public class JobRunner extends EventHandler implements Runnable {
@@ -345,9 +344,9 @@ public class JobRunner extends EventHandler implements Runnable {
this.azkabanProps
.getString(Constants.ConfigurationKeys.AZKABAN_SERVER_LOGGING_KAFKA_TOPIC));
- final JSONObject layout = LogUtil.createLogPatternLayoutJsonObject(this.props, this.jobId);
+ final String layoutString = LogUtil.createLogPatternLayoutJsonString(this.props, this.jobId);
- kafkaProducer.setLayout(new PatternLayoutEscaped(layout.toString()));
+ kafkaProducer.setLayout(new PatternLayoutEscaped(layoutString));
kafkaProducer.activateOptions();
this.flowLogger.info("Created kafka appender for " + this.jobId);
diff --git a/azkaban-exec-server/src/main/java/azkaban/execapp/LogUtil.java b/azkaban-exec-server/src/main/java/azkaban/execapp/LogUtil.java
index 90dcc45..7411806 100644
--- a/azkaban-exec-server/src/main/java/azkaban/execapp/LogUtil.java
+++ b/azkaban-exec-server/src/main/java/azkaban/execapp/LogUtil.java
@@ -22,7 +22,7 @@ import org.json.simple.JSONObject;
class LogUtil {
- static JSONObject createLogPatternLayoutJsonObject(Props props, String jobId) {
+ static String createLogPatternLayoutJsonString(Props props, String jobId) {
final JSONObject layout = new JSONObject();
layout.put("category", "%c{1}");
layout.put("level", "%p");
@@ -37,6 +37,6 @@ class LogUtil {
layout.put("projectversion",
props.getString(Constants.FlowProperties.AZKABAN_FLOW_PROJECT_VERSION));
layout.put("logsource", "userJob");
- return layout;
+ return layout.toString();
}
}
diff --git a/azkaban-exec-server/src/test/java/azkaban/execapp/LogUtilTest.java b/azkaban-exec-server/src/test/java/azkaban/execapp/LogUtilTest.java
new file mode 100644
index 0000000..1eb711d
--- /dev/null
+++ b/azkaban-exec-server/src/test/java/azkaban/execapp/LogUtilTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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 azkaban.execapp;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import azkaban.utils.Props;
+import org.junit.Test;
+
+public class LogUtilTest {
+
+ @Test
+ public void createLogPatternLayoutJsonObject() throws Exception {
+ final String jobId = "jobId1";
+ final Props props = Props.of("azkaban.flow.projectname", "projectFoo",
+ "azkaban.flow.flowid", "flowId1",
+ "azkaban.flow.submituser", "submitUserFoo",
+ "azkaban.flow.execid", "execId1",
+ "azkaban.flow.projectversion", "projectV1");
+ final String expected = "{\"jobid\":\"jobId1\","
+ + "\"projectname\":\"projectFoo\","
+ + "\"level\":\"%p\","
+ + "\"submituser\":\"submitUserFoo\","
+ + "\"projectversion\":\"projectV1\","
+ + "\"category\":\"%c{1}\","
+ + "\"message\":\"%m\","
+ + "\"logsource\":\"userJob\","
+ + "\"flowid\":\"flowId1\","
+ + "\"execid\":\"execId1\"}";
+ final String result = LogUtil.createLogPatternLayoutJsonString(props, jobId);
+ assertThat(result).isEqualToIgnoringWhitespace(expected);
+ }
+
+}