Log4j2 Async Logger

446 views
Skip to first unread message

Guido Medina

unread,
Dec 19, 2015, 1:12:12 PM12/19/15
to Akka User List
Hi,

Is there any implementation of Akka Log4j2 without using an intermediary actor? See, I want to use Log4j2 asynchronous appender's LMAX implementation which combined with RollingRandomAccessFile buffering and asynchronous flushing techniques in general is supposed to be gigantically faster than queuing the messages to an actor.

I read the Akka logging documentation but it is not clear how to come up with your own implementation and let know Akka about so that Akka messages are also sent there, I don't want to use Slf4j or Log4j2 directly, what class do I need to implement in Java to pass my own logging implementation? Any example in Java without an intermediary actor?

Log4j2 asynchronous appenders at the moment according to benchmarks is the fastest today: http://logging.apache.org/log4j/2.x/manual/async.html

Thanks a lot,

Guido.

Patrik Nordwall

unread,
Dec 20, 2015, 4:38:48 AM12/20/15
to Akka User List
Log4j2 is probably (I have not used it) great, but be aware of that it will block if the ring buffer is full, which can potentially block many actors if logging is performed directly from the actors.
--
>>>>>>>>>> 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.

Guido Medina

unread,
Dec 20, 2015, 5:30:20 AM12/20/15
to Akka User List
Hi Patrik,

Yes, I'm aware of it, but for non-log4j2 cases you could have too many messages on an actor using the main Akka dispatcher and have it busy with I/O operations, in my case I will have a decent amount of logging so I would like problem to be resolved with the new and ludicrous speed offered by Log4j2 which tackles the problem with 2 combined approaches:
  • asynchronous logging with LMAX RingBuffer which I can always expand via configuration.
  • I/O buffering built-in that is part of some new appenders.
These 2 approaches make Log4j2 at least twice as fast and keep the server I/O less busy so I think a SyncSlf4JLogger and SyncLog4JLogger should be offered by akka-slf4j and akka-log4j plugins for people that know what they are doing or want more freedom and control over their logging approach.

Best regards,

Guido.

Heiko Seeberger

unread,
Dec 20, 2015, 6:34:04 AM12/20/15
to akka...@googlegroups.com
Hi Guido,

If I understand correctly, you want to use Log4j2 directly. What exactly should Akka offer here?

Regards
Heiko

--

Heiko Seeberger
Twitter: @hseeberger

Guido Medina

unread,
Dec 20, 2015, 6:53:33 AM12/20/15
to akka...@googlegroups.com

I want Akka system messages to also be logged hence cannot use directly but only via registration on the configuration just like you do for akka-slf4j and your akka-log4j.

You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/6UQbAICDJG0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.

Guido Medina

unread,
Dec 20, 2015, 7:17:33 AM12/20/15
to Akka User List
Sorry for brevity writing from phone which I hate.

In a nutshell I would like your plugin akka-log4j to offer an extra class to log directly without an actor in between which is your current implementation, same applies for akka-slf4j.

That way Akka system has a registered logger and my actors will continue obtaining the logger instance from Akka system.

Heiko Seeberger

unread,
Dec 20, 2015, 10:22:50 AM12/20/15
to akka...@googlegroups.com
Got it. Unfortunately that’s not possible right now because of the design of Akka’s logging facility which is made up from a frontend (the API you actually use for logging, based on Akka’s Actor based event stream) and the specific backend (e.g. akka-log4j).

Maybe something to consider for Akka Typed? Roland?

Heiko


--

Heiko Seeberger
Twitter: @hseeberger

Guido Medina

unread,
Dec 20, 2015, 11:20:07 AM12/20/15
to Akka User List, loe...@posteo.de
Hi Heiko,

Now I could say hi 'cause I got my laptop back, my wife hijacked it few hours ago.
Here is the situation I'm facing which in the end is nobody's fault, bunch of APIs using different logging facilities, at the moment here is the list of APIs that logs:
  • Akka with actor, remote and cluster which I delegated to akka-log4j2
  • EclipseLink which I wrote my own Log4j2SessionLogger.
  • Vert.x which I have implemented their provided LogDelegate libraries.
  • HikariCP which uses Slf4j which I bridged with Log4j2 synchronous library calls.
So with that list you can imagine it is not worth having an occupied actor doing logging -nor the main dispatcher-, instead let me use what handles that concern properly which in this case is Log4j2 async appenders blah blah.

It might block, it might saturate, is OK but at least I'm now sure my whole application is logging asynchronously and it is centralized to an area that I have more control and can mitigate, I even have an async log4j2.xml for the console for my development environment and another async rolling files for test and production environments.

That said, I think it is now worth having such freedom of choice between log sync or async, don't you think?

Best regards,

Guido.
Reply all
Reply to author
Forward
0 new messages