I am working with log4net. I wants to add a button in my GUI that when the user click on that button, the log file will cleared. How can I do that?
Thanks alot
I had this issue, too.
You need this in your config:
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
It is not supported "out of the box" from log4net. However, you could using the RollingFileAppender and create a manual class/method to clean up/delete the log file.
For reference, Log4Net: set Max backup files on RollingFileAppender with rolling Date
Another approach to avoid the file being locked would be to set the minimal locking level on the log file via:
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With