prateekm commented on a change in pull request #1003: Removing 
job.diagnostics.appender.class config, and populating it based on if log4j or 
log4j2 is class-loaded
URL: https://github.com/apache/samza/pull/1003#discussion_r276862766
 
 

 ##########
 File path: 
samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala
 ##########
 @@ -903,14 +903,22 @@ class SamzaContainer(
       info("Starting diagnostics.")
 
       try {
-        val diagnosticsAppender = 
Class.forName(config.getDiagnosticsAppenderClass).
-          
getDeclaredConstructor(classOf[SamzaContainerMetrics]).newInstance(this.metrics);
+        var diagnosticsAppender = 
Util.getObj("org.apache.samza.logging.log4j.SimpleDiagnosticsAppender", 
(classOf[SamzaContainerMetrics], this.metrics))
+        info("Attached log4j diagnostics appender.")
       }
       catch {
         case e@(_: ClassNotFoundException | _: InstantiationException | _: 
InvocationTargetException) => {
-          error("Failed to instantiate diagnostic appender", e)
-          throw new ConfigException("Failed to instantiate diagnostic appender 
class " +
-            config.getDiagnosticsAppenderClass, e)
+          try {
+            val diagnosticsAppender = 
Util.getObj("org.apache.samza.logging.log4j2.SimpleDiagnosticsAppender", 
(classOf[SamzaContainerMetrics], this.metrics))
+            info("Attached log4j2 diagnostics appender.")
+          } catch {
+            case e : Throwable => {
+              warn("Failed to instantiate neither diagnostic appender for 
sending error information to diagnostics stream", e)
 
 Review comment:
   Should not ignore throwables. Maybe catch specific exceptions / Exception?

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


With regards,
Apache Git Services

Reply via email to