Question about loggers

M

markspace

Isn't that the argument we discussed last week and after Arveds test
could conclude was completely BS?


Just to chime in here, that other thread got so long and convoluted I
stopped reading it. Sorry if some of my posts here duplicated recently
discussed topics.
 
A

Arne Vajhøj

Just to chime in here, that other thread got so long and convoluted I
stopped reading it. Sorry if some of my posts here duplicated recently
discussed topics.

The conclusion was that logger in a shared classloader was indeed a
disaster, but that static versus non-static did not matter.

Arne
 
A

Arne Vajhøj

On 3/9/2012 8:03 AM, Arne Vajhøj wrote:
###Probably the blindingly obvious point that O(1) instantiation of the
###logger is better than a per-object O(n) instantiation.
All of which is O(n), and which takes time and CPU cycles.

It is still not instantiation.

And it does not change big O of anything.

It do add little bit of overhead. But I can not
see that being a real problem.

Arne
 
L

Lew

Probably the blindingly obvious point that O(1) instantiation of the
logger is better than a per-object O(n) instantiation.

A difference that makes no difference is no difference.

Beware premature optimization.

I suppose I'm just saying that making recommendations based on "efficiency"that affects something like 10^-6 proportion of runtime is grandiose at best. Going after the most minuscule contributor to efficiency first is not efficient. Ergo, taking overall efficiency into account, not just the negligible contribution of CPU at runtime but the significant contribution of engineering time over the life cycle, that advice is counter to the goal of efficiency.

Bear in mind that we're only talking about the cost of a reference; the logger object itself is only instantiated once per class using the discussed-to-death convention of identification of
the logger with the class.

I recommend scoping the logger as any other variable - to the scope of its use.
 
L

Lew

markspace said:
Just to chime in here, that other thread got so long and convoluted I
stopped reading it. Sorry if some of my posts here duplicated recently
discussed topics.

So you deliberately didn't read the posts and now ask forgiveness for your intentional act ofïœ omission and consequent duplication of recentlywell-hashed-out issues.

Very well, I forgive you.
 
R

Robert Klemme

By "application" do you mean JEE app or desktop app?

It's not me! I am just quoting. Please read what they write.
Either way, I don't understand your assertion. Why would static vs.
instance make any difference in a library, assuming no shared or other
special classloaders are in use?

Again: it's not my assertion. You were the one who brought up best
practices from Apache Commons:

Also be aware that while static loggers are common in Java in general,
instance loggers are recommended best practice according the the Apache
Commons website.

I was just pointing out that what you claimed Apache Commons best
practices is (instance loggers as _general_ best practice) is not what
they are actually stating (instance loggers for _library code_).

Cheers

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top