[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Why are Loggers static members in classes
|
Am 25.11.2013 17:39, schrieb Joakim Erdfelt:
> Why are you using logging event messages?
> LifeCycle events (like in your example) can be monitored using
> a LifeCycle.Listener.
Features like LifeCycle events are not the point since AbstractLifeCycle
was just an example. Another one is org.eclipse.jetty.server.Server.
This is a class that can be expected to be instantiated only once
(or twice in my specific application) during the whole runtime of
the server, so the argument that it's avoiding excessive garbage
collection is even less convincing. Currently it more looks like
an OSI-10-level-reason than a technical one.
Strictly speaking this is a premature optimization (or are there
actual numbers showing that an existing bottle neck was fixed this
way?) coming with some implications for real life applications:
- Setting a logger programmatically only works if it happens before
any classloading of Jetty-classes (except the Log-class of course).
- Changing the type of logger during runtime isn't possible anymore
- The success of setting the logger is non-deterministic. If you add
a jar to your classpath that lead to the loading of Jetty-classes
you lose again.
If you have an application that runs as Windows Service all output on
STDOUT/STDERR will be added to the Windows Event Log. Every single line
is a new entry. So if you don't get the logger changed successfully and
activate debugging, your Windows Event Log will explode while you're
wondering, why your own server-log still only contains the log-messages
of your own classes (if there are any).
That's one of the reasons why I test the log-messages (instead of e.g.
get LifeCycle-events). I want to make sure that the setting of the
logger works (it already was quite some work in the past, so I test
that now). The example in my last mail was only intended to show the
impossibility to set the logger in a reasonable way, there are others
that fail as well for the same reason.
Regards, Lothar