Re: File handle on Windows

2017-01-31 Thread Clément Guillaume
Found it. I'm able to delete the file after calling LoggerContext.stop(). Is there a recommended practice between calling Configurator.shutdown(LoggerContext) or LoggerContext.stop()? On Tue, Jan 31, 2017 at 1:51 PM, Clément Guillaume wrote: > I looked at the unit tests. I'm using testng for the

Re: File handle on Windows

2017-01-31 Thread Clément Guillaume
I looked at the unit tests. I'm using testng for the tests, so I'm trying to replicate the behavior of those rules by basically calling Configurator.shutdown(LoggerContext), but I think I have some trouble getting the right context to call it on. On Tue, Jan 31, 2017 at 1:09 PM, Christopher Schult

Re: File handle on Windows

2017-01-31 Thread Christopher Schultz
Clément, On 1/31/17 1:17 PM, Clément Guillaume wrote: > I have a unit test, using log4j 2.8 to log to a file using a FileAppender, > that deletes the log file at the end of the test. This test works well on > linux, but fails on Windows because the java process still has a file > handle to the log

Re: File handle on Windows

2017-01-31 Thread Gary Gregory
On Tue, Jan 31, 2017 at 10:56 AM, Apache wrote: > I would recommend looking at the Log4j unit tests and using the > LoggerContextRule with the withCleanFoldersRule like > RollingAppenderCronTest does or the withCleanFilesRule like > RoutingAppenderTest does. The key is that these delete the files

Re: File handle on Windows

2017-01-31 Thread Apache
I would recommend looking at the Log4j unit tests and using the LoggerContextRule with the withCleanFoldersRule like RollingAppenderCronTest does or the withCleanFilesRule like RoutingAppenderTest does. The key is that these delete the files after Log4j has shut down so the file handles are clos

Re: File handle on Windows

2017-01-31 Thread Clément Guillaume
It doesn't help, when DeleteOnExitHook is called the file handle is still there On Tue, Jan 31, 2017 at 10:26 AM, Remko Popma wrote: > You can try calling File.deleteOnExit(). > > On Wed, Feb 1, 2017 at 3:17 AM, Clément Guillaume > wrote: > > > Hi, > > > > I have a unit test, using log4j 2.8 to

Re: File handle on Windows

2017-01-31 Thread Remko Popma
You can try calling File.deleteOnExit(). On Wed, Feb 1, 2017 at 3:17 AM, Clément Guillaume wrote: > Hi, > > I have a unit test, using log4j 2.8 to log to a file using a FileAppender, > that deletes the log file at the end of the test. This test works well on > linux, but fails on Windows because