Bug 53620

Summary: [juli] delay opening a file until something gets logged
Product: Tomcat 7 Reporter: Karol Bucek <karol.bucek+apache>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: patch
Delayed file opening changes

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