C
C
Constanine2020-02-27 01:50:46
Java
Constanine, 2020-02-27 01:50:46

What books, articles, best practices can be studied to organize application logging?

Now I am writing my personal project on parsing html pages. I am using jsoup. In the process of debugging, a large amount of code was obtained, mixed with prints. I would like to put all this in order and implement an enable / disable logging mechanism, followed by output to files.

What will the community advise you to get acquainted with in order to implement your plan? I would like to organize a mechanism, at least remotely similar to those used in "adult projects / systems".

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2020-02-27
@Constanine

I will advise log4j and slf4j as a wrapper for it. Use the API from slf4j, which stacks logs through log4j or some other logging library.
www.slf4j.org/manual.html
Why this approach is good - you have only slf4j in your dependencies, which itself determines which logging mechanism the application uses. And actually this mechanism can be painlessly changed in the future.
It is especially good to do this in libraries, because the application can use anything.
Typically, all libraries work for me through SLF4J, and yes, there is a simple logger slf4j-simple-XXX.jar included if you don’t need something fancy like log4j.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question