Change in properties for logging: deliberate?
Daniel Fuchs
daniel.fuchs at oracle.com
Mon Nov 13 15:30:01 UTC 2017
Hi Jason,
On 13/11/2017 15:14, Jason Mehrens wrote:
> Hi Daniel,
>
> Sorry for the late reply I was offline for the long weekend.
>
> Hot reloads of the LogManager have always been a problem. I think you are running into https://bugs.openjdk.java.net/browse/JDK-8033661 in your testing and that is going to give you troubling results on what is recreated after the call. Make sure you test updateConfiguration which is the replacement everyone is to use going forward.
Yes - I know - I fixed that one ;-)
> I think you'll want to make it so that "handlers" is just an alias name ".handlers". That way empty string is just name of the root logger which enables consistent use of other properties like ".level" and ".filter".
> If both are defined in the logging.properties, then install the union of the two line.
That's precisely where I didn't want to go.
When I fixed JDK-8033661 I choose to use "handlers" for the root logger
instead of ".handlers" when implementing updateConfiguration() because
"handlers" is explicitly documented in LogManager API documentation
and conf/logging.properties.
So for the root logger the mapping function will only consider
"handlers" but not ".handlers". Trying to change that would
add too much complexity IMHO.
best regards,
-- daniel
>
> Jason
>
> ________________________________________
> From: Daniel Fuchs <daniel.fuchs at oracle.com>
> Sent: Friday, November 10, 2017 10:04 AM
> To: Jason Mehrens; mandy chung
> Cc: core-libs-dev at openjdk.java.net
> Subject: Re: Change in properties for logging: deliberate?
>
> Hi Jason,
>
> I have done a few tests with JDK 8 & 7.
>
> I have created custom handlers and added some
> debug traces in their constructors and debug methods.
>
> Then I have added these two lines to my logging.properties:
>
> handlers = custom.Handler
> .handlers = custom.DotHandler
>
> What I see is this:
>
> - the first time the configuration is read, two handlers
> are added to the root logger:
> - an instance of DotHandler (first), then an instance
> of Handler (second).
>
> Then if you call LogManager.readConfiguration() again,
> both handlers are closed, and this time only one
> instance of Handler is added to the root logger.
> No instance of DotHandler is added.
> From now on the property is ignored.
>
> This is because the root logger is a special beast:
> it will not be removed (like all other loggers) when
> LogManager.readConfiguration() is called.
>
> And as it happens, handlers are added to loggers
> when the loggers are added to the LogManager.
> As it happens, the ".handlers" property is only parsed
> and read when the root logger is added to the LogManager,
> and thus only once.
>
> The "handlers" property on the other hand is parsed
> every time LogManager.readConfiguration() is called.
>
> Given that, I suspect we should deprecate the use of
> ".handlers" for the root logger, as it appears that
> it has never worked properly. I could work on a patch
> for 10 (possibly backport it to 9 update) to preserve
> the strange behavior of 7 & 8, but is it worth it?
>
> What are your thoughts?
>
> best regards,
>
> -- daniel
>
>
>
>
> On 09/11/2017 19:50, Jason Mehrens wrote:
>> Daniel,
>>
>> I would assume you would fix since it is advertised as a feature over here: https://docs.oracle.com/javase/1.5.0/docs/guide/logging/changes.html
>>
>> If it helps, I've dug up a lot of the history on this over here a while back:
>> https://stackoverflow.com/questions/36726431/in-a-java-util-logging-logging-properties-file-whats-the-difference-between-h
>>
>> I've updated that to include the links to this new issue. Now that I've linked this message thread to that message thread that should crash the internet. :)
>>
>> Jason
>>
>> ________________________________________
>> From: core-libs-dev <core-libs-dev-bounces at openjdk.java.net> on behalf of Daniel Fuchs <daniel.fuchs at oracle.com>
>> Sent: Thursday, November 9, 2017 1:29 PM
>> To: mandy chung
>> Cc: core-libs-dev at openjdk.java.net
>> Subject: Re: Change in properties for logging: deliberate?
>>
>> On 09/11/2017 19:16, mandy chung wrote:
>>> Daniel - we should add this known issue in the release note and document
>>> the workaround.
>>
>> Hi Mandy,
>>
>> Right, it either need to be fixed, or documented in the release
>> notes. Let me first have a look at the issue though.
>>
>> best regards,
>>
>> -- daniel
>>
>
More information about the core-libs-dev
mailing list