Is SLF4J good for use in a multi-threaded database logging application?



I am working on a multi-threaded application. I already use Log4j to register statements in files.
I recently explored the ability to log into a Mysql database.

The logging component must be reliable under heavy load and must be thread safe.
I heard about SFL4J. My understanding of SLF4J is just a layer of facade or abstraction.

  • I was wondering if SLF4J was a good database logging solution for use in a multi-threaded application?

  • And in case of heavy load, it would be nice to add a layer (for example, a buffer or a queue), and let the threads access it, and not directly access the log stream (the log stream will send the statements found in the queue one by one to the database) ?

Any tips, tricks or code examples would be greatly appreciated,
Yours faithfully,

+4
source share
1 answer

You are right that SFL4J is just a facade, it allows library and framework writers to carry out their journaling through the facade and have an application that defines their own journal structure. At the application level, it is not so convincing to use SLF4J, you can also use log4j directly. The only advantage would be that you could switch to logback in the future with less changes. This is not all that convincing if you do not have a case where you do not know which logging implementation you want to go with, in which case you could use an abstraction layer so that you can replace the implementations in comparison tests.

If you use SLF4j, I don't think that would affect concurrency. You might want to consider different applications (or translate their own) for the actual registrar, but that will not affect what you called SLF4J. The only place concurrency will affect is the application.

+2
source

Source: https://habr.com/ru/post/1443231/


All Articles