Bug 53620 - [juli] delay opening a file until something gets logged
Summary: [juli] delay opening a file until something gets logged
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-07-30 08:55 UTC by Karol Bucek
Modified: 2020-01-16 19:51 UTC (History)
0 users

patch (9.67 KB, patch)
2012-07-30 08:55 UTC, Karol Bucek
Details | Diff
Delayed file opening changes (2.99 KB, patch)
2018-11-16 18:41 UTC, Mark Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karol Bucek 2012-07-30 08:55:29 UTC
Created attachment 29137 [details]

had troubles configuring the FileHandler while bootstraping Tomcat, this patch sums up a few (minor) changes that allows one to setup a FileHandler instance programatically. the changes are the following :

- delay opening a file until something gets logged (since the code is already there within publish() to support rolling it kind of made sense to open the file from publish() instead of the constructor)
- add a constructor where all 'configurable' properties of the handler can be provided programatically 
- since FileHandler.close() is public API so should be open()

I'm very sorry to have no tests, I've happened to test the desired FileHandler "behavior" with https://github.com/trinidad/trinidad and is currently contained within the 1.4.0 release of Trinidad.
Comment 1 Mark Thomas 2018-11-16 18:40:37 UTC
Apologies for the delay in getting to this.

Making open() public is likely to break any custom sub-classes. It seems likely that such classes might exist so I intend to skip that part of the patch.

I've applied the constructor changes to 9.0.x for 9.0.14 onwards.

The changes to delay opening the file break sub-classes so those need to wait until 10.x. I'll attach a patch with these specific changes.
Comment 2 Mark Thomas 2018-11-16 18:41:08 UTC
Created attachment 36265 [details]
Delayed file opening changes
Comment 3 Mark Thomas 2020-01-16 19:51:47 UTC
It took a little longer but Tomcat 10 is now under development so I have applied these changes.

Fixed in:
- master for onwards