Answer the question
In order to leave comments, you need to log in
How to work normally with java.util.logging?
in my small coursework project I am writing a server in Java.
for logs I use java.util.logging, declare my Logger and Formatter, add FileHandler and ConsoleHandler that use this Formatter.
but for some reason the logs seem to be 3, although I added 2. duplicate messages are displayed in the console, but with a different formatting.
I have an assumption that some Handler is sewn up in the Logger by default, which displays the third messages, which is logical in general. but I can't get rid of it! I can't find any trace of him!
Question: how can I get rid of this default Handler?
Googling and reading the docks somehow didn’t help - poor knowledge of English interferes :)
Answer the question
In order to leave comments, you need to log in
Thanks, I will know, but you did not help me, but only distracted me from the question.
happy with yourself?
Dig into the ConsoleHandler sources. It uses System.err for output, and an attempt to replace it through inheritance causes the closure (!) of the stream.
So it's better in this case not to use ConsoleHandler, but to write your own, inheriting from StreamHandler'a.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question