Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Why are Loggers static members in classes

Do this ...

Create a src/test/resources/jetty-logging.properties 
Specify your own Logger implementation there.

See some of our own test cases ...
https://github.com/eclipse/jetty.project/blob/master/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties

Static loggers are there to limit GC churn for something that is not instance dependant, and is an extremely common logger pattern.
You can also use Log.setLog(Logger) to specify your own Logger impl.

Example:
https://github.com/eclipse/jetty.project/blob/master/jetty-util/src/test/java/org/eclipse/jetty/util/log/LogTest.java


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Mon, Nov 25, 2013 at 5:41 AM, Lothar Kimmeringer <job@xxxxxxxxxxxxxx> wrote:
Hi,

is there a very good reason, why Jetty-classes are setting a
private final static member for the logger being used for
logging? At the moment I have failing testcases and non-deter-
ministic behavior because I'm practically unable to set my own
Logger in 100% percent of all cases.

The ability to do so requires me to set the Logger before any
classloading of jetty-classes have taken place which is practically
impossible e.g. in a Junit-testcase and quite a hassle when
embedding Jetty in your own application.

I got it embedded but now it seems that I have to change all my
tests that check the logs in addition to the functionality (I do
additional logs to the ones being done by Jetty standard-classes)
which means in essence that I lose test-coverage.


Regards, Lothar
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top