Order of log lines is mixed when 3rd party logs write directly to SLF4J

12 views
Skip to first unread message

Natanel Savion

unread,
Jun 19, 2017, 9:28:37 AM6/19/17
to Akka User List
Hi,
While using in akka's infrastructure (akka.event.Logging), log lines are written asynchronously.
If 3rd party code that writes directly to SLF4J runs within the context of an actor, this can lead to condition where akka code performed before the 3rd party code only gets logged after the 3rd party log due to the time it takes the logs to be written async.

%X{akkaTimestamp} (see http://doc.akka.io/docs/akka/current/java/logging.html#more-accurate-timestamps-for-log-output-in-mdc) can be used to reorder the log but sometimes the timestamp resolution is not sufficient to reliably order the lines.

Was wondering if someone else may have encountered this problem and came-up with some solution. 
Currently, we are considering writing all our logs directly to SLF4J to avoid this issue (the SLF4J back-end can be configured with an async appender to provide similar functionality).

Thanks,
Nati

 


Konrad Malawski

unread,
Jun 19, 2017, 9:33:50 AM6/19/17
to akka...@googlegroups.com, Natanel Savion
You can always just us slf4j directly - use an async appender in the impl (logback2 AFAIR provides one and others as well) and you're good.

There's no requirement to use ActorLogging, we only have it to not depend on a specific logging API in akka-actor itself.

-- 
Konrad `ktoso` Malawski
Akka @ Lightbend
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Natanel Savion

unread,
Jun 19, 2017, 10:03:45 AM6/19/17
to Akka User List, natanel...@gmail.com
Thanks for the quick response!  
Reply all
Reply to author
Forward
0 new messages