Bug 59871 - Impossible to change datetime format in OneLineFormatter/Use sane (sortable) format
Summary: Impossible to change datetime format in OneLineFormatter/Use sane (sortable) ...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.3
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-16 21:37 UTC by Michael Osipov
Modified: 2016-08-03 16:55 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2016-07-16 21:37:06 UTC
The OneLineFormatter is a tremendous improvement to the formatter shipped with default Java, though one cannot change the datetime format nor does it have a sane, standardized, sortable format. I don't want to write a custom formatter or fork this one just to change this property.

I would actually expect that the formatter would use wellknown ISO 8601 datetime for the default output: yyyy-MM-dd'T'HH:mm:ss.SSS. Alternatively, one can use String#format, though I do not know wether this will beat the benefit of the DateFormatCache.
Comment 1 Remy Maucherat 2016-07-18 12:19:43 UTC
There is no provision to be able to set properties on the fomatters, so it is more difficult to add this support. Adding your own formatter is not very difficult and is the way to go here, so you're going to have to do that.
Comment 2 Michael Osipov 2016-07-18 12:43:49 UTC
(In reply to Remy Maucherat from comment #1)
> There is no provision to be able to set properties on the fomatters, so it
> is more difficult to add this support. Adding your own formatter is not very
> difficult and is the way to go here, so you're going to have to do that.

That's a JULI shortcoming. Why not provision a standards format then?
Comment 3 Konstantin Kolinko 2016-07-18 14:16:00 UTC
(In reply to Remy Maucherat from comment #1)
> There is no provision to be able to set properties on the fomatters,

That is not true.
It is not documented, but formatters can be configured. It is the same as with other classes,  [<prefix>.]<classname>.<property>

The <prefix>. is either omitted (to be applied to all instances of a Formatter), or has to be the same as prefix of the Handler to which this formatter belongs.

See example in bug 55052

java.util.logging.SimpleFormatter is a bad class / bad example, as it can be configured only once and caches its configuration in a static variable.
Comment 4 Remy Maucherat 2016-07-18 14:27:54 UTC
Ok, I really don't understand how this works looking at the FileHandler code, but nice to know.
Comment 5 Mark Thomas 2016-08-02 21:32:53 UTC
This is now configurable in 9.0.x (for 9.0.0.M10 onwards) and 8.5.x (for 8.5.5) onwards.
Comment 6 Michael Osipov 2016-08-03 16:55:18 UTC
(In reply to Mark Thomas from comment #5)
> This is now configurable in 9.0.x (for 9.0.0.M10 onwards) and 8.5.x (for
> 8.5.5) onwards.

Thank for the fix. Though, there is absolutely no documentation. So people won't know about it at all :-(