dev@glassfish.java.net

Re: logger printing message param twice

From: Fabian Ritzmann <Fabian.Ritzmann_at_Sun.COM>
Date: Tue, 27 Feb 2007 15:57:22 +0200

kedar wrote:
> I understand that this is a bit clumsy, but error messages and
> diagnosis guide is based on this.

Do you have a link to said guide? I didn't find anything with a quick
google query. I've struggled quite a bit with the logging "guidelines",
which seem somewhat outdated and incomplete [1].

Fabian

[1] Can't really blame that document, it's obviously never been intended
as an implementation guide:
https://glassfish.dev.java.net/logging/GlassFishLog_guidelines.html

> Byron Nevins wrote:
>> I've never heard of this behavior -- and I write lots of similar
>> messages. If the String is in LocalStrings.properties in the class'
>> package -- then I would do this:
>>
>> import com.sun.enterprise.util.LocalStringsImpl;
>>
>> yourCode()
>> {
>> LocalStringsImpl stringy = new LocalStringsImpl();
>> String s = stringy.get("some_key", someObject);
>> logger.log(SEVERE, s);
>> }
>> Now you at least have a chance of figuring it out via a debugger...
>>
>>
>> Bobby Bissett - Javasoft wrote:
>>> I have code that is logging a Level.SEVERE message as so:
>>>
>>> logger.log(Level.SEVERE, "some_key", someObject);
>>>
>>> With log string:
>>>
>>> some_key=My message {0}
>>>
>>> In the log output, I'm seeing the someObject.toString() text twice,
>>> once before "My message" and once again after. Is this by design? It
>>> creates too much output this way (the object is an expired cert and
>>> it prints ~25 lines).
>>>
>>> I see in UniformLogFormatter.uniformLogFormat() it calls
>>> getNameValuePairs() before appending the message and object, and
>>> getNameValuePairs() appends someObject.toString() before returning
>>> so that the same information is in the log message twice.
>>>
>>> Can someone tell me if this is a bug? If not, is there a different
>>> way to call the logger so I don't generate this much output? I would
>>> like to give as much information as possible in this message (it's
>>> SEVERE), but I don't want to give it twice.
>>>
>>> Thanks,
>>> Bobby
>>>
>>>
>>>