Open hp77-creator opened 3 years ago
Doesn't have to be java util logging, just should probably use a proper logger
what are the other options @timja , I know about log4j, and what do you mean by a proper logger, is java.util.logging not a proper logger?
it is yes although it's not very user friendly, but most of Jenkins seems to use it for some reason so maybe best to stick to it.
here's a link with some other ones: https://stackify.com/compare-java-logging-frameworks/
I don't have any issue in using other library, do we need to follow the trend of using JUL? Going through that link, I just saw that log4j has been archived, log4j2 is the currently developed library while I read somewhere that many prefer slf4j with logback over JUL, so I will explore all of these, And will update you with the preferred option. Frankly I have never used JUL in any of the project so idk what nuances it presents, I will try it.
The api is just... bad
But fine to keep the status quo and use JUL
log4j2 is the most modern logger java has as far as I know with logback over slf4j being the second choice normally
I see! :sweat_smile: tbh they seemed fine to me, There are levels defined which can be then used to print the logs(This shows the knowledge of logging that I have at the moment, don't know of its behaviour in printing to file or console), but if you have any example in mind, I would love to hear those, and can you also shed some info on how do you categorise APIs to be bad or good, Maybe I will learn to write/use them better in the process. Thanks.
JUL has very limited parameters for the level specific methods,
logger.warn("")
etc only take very limited parameters.
99% of the time you end up having to do:
logger.log(Level.WARN, "My message", e)
and then if you want to pass parameters to your log message you need to create an object array and you the MessageFormat
string format which is not that nice either
@timja, What format should I keep for the log messages?Default one prints out
Date time Class name Method name
Level: Message
like this:
May 20, 2021 6:52:20 PM io.jenkins.tools.pluginmanager.impl.PluginManager getJson
INFO: Cache miss for: plugin-versions
I don't think anything should be there at all other than the message
not even the level? Like how it is in maven?
no it's a CLI, try out some other CLI tools and see the output they give, a debug / verbose level log could maybe add some more information
I have used some linux cli tools, and yep they give some additional information in verbose mode, so you are suggesting to add some more info here or you are saying it is too much for a non verbose mode? I am sorry I don't understand that part.
Yea, additional log4j logging capability would really help debug when your troubleshooting your corporate proxy connection. Need to see headers to and from for the plugins download http calls.
Currently the tool uses System out for logging. It would be great to switch to Java Util Logging so that the tool can be used as a library in Jenkins components.
Reporter: Oleg Nenashev
202
10