Skip to main content

Unhappy about Logger.global deprecation

9 replies [Last post]
cayhorstmann
Offline
Joined: 2003-06-13

Apparently, Logger.global is now deprecated: "Initialization of this field is prone to deadlocks. The field must be initialized by the Logger class initialization which may cause deadlocks with the LogManager class initialization. In such cases two class initialization wait for each other to complete. As of JDK version 1.6, the preferred way to get the global logger object is via the call Logger.getLogger(Logger.GLOBAL_LOGGER_NAME)."

I like using Logger.global to entice beginning programmers into logging. "Just change System.out.println into Logger.global.info". Same number of keystrokes... (I don't tell them about the import :-))

Logger.getLogger(Logger.GLOBAL_LOGGER_NAME) isn't going to win the hearts and minds of those programmers.

I know it's a small thing, but these small things matter when you try to get lazy people to stop using S.o.p.

Surely someone can figure out a way to solve that. After all, we have System.out :-)

Cay

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kellyohair
Offline
Joined: 2004-09-03

We really scratched our heads hard on this problem, so please don't think we decided this lightly. The deadlock was a serious problem we needed to fix. We tried various solutions but the way the logging code was written created numerous road blocks to a good fix that didn't create a different deadlock or create a new API that we didn't have time to deal with (this work happened late in the release). These static fields are very problematic in this logger code and we really need an expert in this area to help out. (public static fields in classes are bad news).

The logging code has not gotten much attention and it consistently falls in the 'low priority' list of features we need to give attention to. Sorry, just telling it like it is so you can understand the situation.

-kto

cayhorstmann
Offline
Joined: 2003-06-13

I agree with numeropi. Adding a getGlobal() (or, if you want to be cute, global()) method that simply calls Logger.getLogger(Logger.GLOBAL_LOGGER_NAME) would solve the problem.

I added a RFE in the bug parade. Is there a better mechanism these days?

sspitsyn
Offline
Joined: 2006-03-13

That was my fault, sorry about that. And thank you for reporting this problem and opening an RFE. I had to add the convenience method getGlobal() when made the 'global' field deprecated. It is relatively easy to fix this new RFE:
6476146: Add convenience method for deprecated Logger.global
It needs to be fixed in the jdk 6 update as well.

numeropi
Offline
Joined: 2006-08-23

Request that a method Logger.getGlobal() be added. That shouldn't be very risky.

jwenting
Offline
Joined: 2003-12-02

who cares?
Sun never removes anything deprecated so you might as well ignore the warnings (and now there's an annotation you can simply have your IDE put on top of every class to do that automatically) and get on with life.

That's of course not what it's meant for, but it is the end result of Sun's obstinate refusal to ever remove anything deprecated.

mthornton
Offline
Joined: 2003-06-10

> Surely someone can figure out a way to solve that.
> After all, we have [b]System.out[/b] :-)

There have probably been a few regrets about System.out as well. I believe it required a special exception in the latest memory model.

erickson
Offline
Joined: 2004-07-07

Java Logging isn't winning the hearts and minds of programmers anyway. I didn't know anyone used it. Anyway, is it worthwhile to cater to someone too lazy to get the right log in the first place?

cayhorstmann
Offline
Joined: 2003-06-13

1) GlassFish uses java.util.logging.

2) Some people use java.util.logging to avoid the "tragedy of the commons" (i.e. having to deal with yet another commons-froufrou.jar).

3) It is [b]always[/b] worth trying to win the hearts and minds of the lazy programmers. That's where 99% of the market is :-)

hopeless
Offline
Joined: 2004-03-17

I'm not particularly pleased with it either since I'd argued for its inclusion in the first place. It's very handy to know you can add a call to Logger.global... into someone elses code whilst debugging and not have to mess around with explicitly getting an Logger instance etc. I guess since it's not the "proper" way of logging (and I'll admit that I don't generally use it) it has a lower priority and they're happy enough to deprecate it. Grrr...