On Tue, Jan 31, 2017 at 10:56 AM, Apache <ralph.go...@dslextreme.com> 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 after > Log4j has shut down so the file handles are closed. > +1, we have lots of tests that clean up after themselves using our custom JUnit rules. Gary > > Ralph > > > On Jan 31, 2017, at 11:17 AM, Clément Guillaume <cguilla...@hotpads.com> > 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 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? > > > > Thank you. > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition <https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459> JUnit in Action, Second Edition <https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021> Spring Batch in Action <https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory