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 <cguilla...@hotpads.com>
wrote:

> 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 Schultz <
> ch...@christopherschultz.net> wrote:
>
>> 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 file, and so the file cannot be deleted.
>> > Any idea how to have the same behavior on the two platforms?
>>
>> What about shutting-down log4j (or the appender) before you try to
>> delete the file?
>>
>> -chris
>>
>>
>

Reply via email to