如何停止log4net记录并释放最后一个文件 [英] How to stop log4net from logging and release the last file

查看:193
本文介绍了如何停止log4net记录并释放最后一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#Win Form App中使用log4net,并且具有开始/停止"切换按钮-

I'm using log4net in C# Win Form App and I have start/stop toggle button -

当我单击开始"时,将加载log4net配置并创建日志文件-工作正常.

When I click "start" the log4net config are loaded and the log file is created - That is working.

但是现在我想添加单击停止"按钮的选项,以停止记录器,当然还要释放文件,因此我可以使用应用程序中的openFileDialog打开它,以读取日志文件文本. StreamReader在多行textbox上显示日志文件.

But now I want to add the option to click "stop" button, for stopping the logger and of course release the file so I could open it with openFileDialog that I have in my app for reading the log file text with StreamReader to show the log file on a multiline textbox.

推荐答案

您可以在运行时修改Threshold.要停止记录,请将其设置为Off.我已经在 answer 中说明了它的工作原理.

You can modify the Threshold during runtime. To stop logging set it to Off. I have already shown how this works in this answer.

这篇关于如何停止log4net记录并释放最后一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆