← Back to context

Comment by varjag

1 month ago

Imagine that you don't need monitoring servers, like possibly the majority of actual log4j deployments?

For example Minecraft uses log4j to write messages to the console and a rotating file.

Technically you can configure it to send to other places - presumably. In practice you'd be better just redirecting stdout, tailing the file, or installing a mod?

  • Honestly unless you insist on allowing running your software on Windows you're much better off delegating the logging to syslog over a thin wrapper. It can handle about anything except most exotic cases. This however goes against Java land portability promises and its NIH attitude so we have what we have.

    • Java is really really good at handling plugins. You can load additional JAR files alongside the app's own JAR file (indeed many apps are shipped as multiple JAR files) and classes from different files are integrated just as well as classes from the same file, and you can load them by name. It's pretty easy to have a command-line option that says "use this logger class instead" and make it the user's problem to supply a suitable class at startup time, and I think this is the way that makes the most sense in Java. It works on any OS and allows more detailed data exchange than just a log string; the logging plugin could even choose to take a stack trace whenever it's called, or read global data like the player's account name.