MarkerLoggingAdapter's error method eating cause parameters #22324

Closed
sumnulu opened this Issue Feb 15, 2017 · 7 comments

Comments

Projects
None yet
5 participants

sumnulu commented Feb 15, 2017 edited

akka.event.MarkerLoggingAdapter does not using cause parameter of the error methods.
akka version = 2.4.16

// ....................
/**
 * [[LoggingAdapter]] extension which adds Marker support.
 * Only recommended to be used within Actors as it isn't thread safe.
 */
class MarkerLoggingAdapter(
  override val bus:       LoggingBus,
  override val logSource: String,
  override val logClass:  Class[_],
  loggingFilter:          LoggingFilter)
  extends BusLogging(bus, logSource, logClass, loggingFilter) {
  // TODO when breaking binary compatibility, these marker methods should become baked into LoggingAdapter itself

  // For backwards compatibility, and when LoggingAdapter is created without direct
  // association to an ActorSystem
  def this(bus: LoggingBus, logSource: String, logClass: Class[_]) =
    this(bus, logSource, logClass, new DefaultLoggingFilter(()  bus.logLevel))

  /**
   * Log message at error level, including the exception that caused the error.
   * The marker argument can be picked up by various logging frameworks such as slf4j to mark this log statement as "special".
   * @see [[LoggingAdapter]]
   */
  def error(marker: LogMarker, cause: Throwable, message: String): Unit =
    if (isErrorEnabled) bus.publish(Error(logSource, logClass, message, mdc, marker))
// ...........

example :

  val s: DiagnosticMarkerBusLoggingAdapter = Logging.withMarker(this)
  s.error(LogMarker("TEST_MARKER"), new UnsupportedOperationException("test"), "contains exception error")
Member

johanandren commented Feb 16, 2017

Did you configure your logger implementation to include the markers in its output (described in the docs for SLF4J here: http://doc.akka.io/docs/akka/2.4.17/scala/logging.html#Using_Markers)?

sumnulu commented Feb 17, 2017 edited

Yes I have. It is logging the markers but not the exception. If I use ActorLogging logback is logging the exception without any problem.

The problem is I think the MarkerLoggingAdapter does not using the cause parameter in the error method's body and just ignoring it. (see my previous comment's first snippet (it is the source code of akka) )

My logsback.xml pattern is like this one:

<pattern>%date{HH:mm:ss} %highlight(%-5level) %boldYellow(%marker) %magenta(%logger{30}) %boldGreen(%X{peerId}) - %msg %ex%n</pattern>
Owner

patriknw commented Feb 20, 2017

@sumnulu I agree, this is an oversight. It doesn't pass on the throwable parameter. Would you be able to create a Pull Request fixing this issue?

sumnulu commented Feb 20, 2017

@patriknw ok, I will.

Owner

patriknw commented Feb 20, 2017

thanks

Member

jrudolph commented Jun 7, 2017

That is solved as part as #23109.

@jrudolph jrudolph added 3 - in progress and removed 1 - triaged labels Jun 7, 2017

raboof was assigned by jrudolph Jun 7, 2017

raboof closed this Jun 7, 2017

Owner

patriknw commented Jun 7, 2017

@raboof I think this is serious enough to warrant a backport to 2.4 (and don't forget to set the milestone)

patriknw reopened this Jun 7, 2017

raboof added this to the 2.5.3 milestone Jun 7, 2017

@patriknw patriknw modified the milestone: 2.4.19, 2.5.3 Jun 9, 2017

patriknw closed this Jun 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment