如何处理自动创建的日志文件. [英] How to handle log file creating autometically.

查看:48
本文介绍了如何处理自动创建的日志文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

网站上有一个文本日志文件,其大小正在不断增加,目前已超过30GB.

问题是我没有从创建它的地方得到它.
我想停止该文件的创建或失败.

谁能帮我.
在此先感谢您.

Dear friends,

There is a text log file in a website, whose size is increasing contineously at present it is over 30GB.

The problem is that i am not geting that from where it is being create.
I want to stop the creation or groth of that file.

can any one help me.
Thanks in advance.

推荐答案

您应该实现日志文件轮换之类的功能.这意味着您的文件每次都大于例如10MB,您可以将其重命名为logger.txt到logger_1.txt.您可以这样做以限制文件的大小,并且可以在不再需要时删除所有旧的logger_x.txt文件.在我们的产品中,我们需要很长的历史记录,但无法处理大型日志文件,因此我们轮流使用了4个文件(每个10MB).
如果您对如何实现有疑问,我们一定会为您提供帮助.
You should implement something like log file rotation. This means everytime your file gets bigger than e.g. 10MB, you rename it from e.g. logger.txt to logger_1.txt. You can do this to limit the size of the file and you can delete all the old logger_x.txt files when no longer needed. In our products we need a long history but can not handle large log files, so we have implemented a rotation of 4 files each 10MB.
If you have questions on how to implement that, we can surely help you.


您可以通过VB.Net代码或在服务器上运行脚本来做到这一点.
如果要通过代码执行此操作,请尝试确保日志的大小不超过限制.
如果是这样,请删除它或重命名它(通过在日期前加上前缀),以便管理员可以删除该文件.

但是,您也可以尝试使用lile log4net来自动将其截断.
You can do this through VB.Net code or by running a script on the server.

If you want to do this through code, try to make sure the size of the log does not exceed a limit.
If it does, either delete it or rename it (by prefixing a date) so that the admininstrator can delete the file.

You could however, also try using something lile log4net which does this truncating automatically.


这篇关于如何处理自动创建的日志文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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