I'm using log4net in my mvc 4 project to log any error & exceptions. My configuration file looks like below
我在我的mvc 4项目中使用log4net来记录任何错误和异常。我的配置文件如下所示
<appender name="AsynchronousLog4NetAppender" type="Umbraco.Core.Logging.AsynchronousRollingFileAppender, Umbraco.Core">
<file value="App_Data\Logs\APIErrorsLog.txt"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<maximumFileSize value="5MB"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
</layout>
<encoding value="utf-8"/>
</appender>
I have also created a view on which I read & output this file's content App_Data\Logs\APIErrorsLog.txt
and show the errors. The issue is a new file is created every day. I guess I can increase the size using maximumFileSize
attribute but how I can stop the creation of new file everyday?
我还创建了一个视图,我在其中读取并输出该文件的内容App_Data \ Logs \ APIErrorsLog.txt并显示错误。问题是每天都会创建一个新文件。我想我可以使用maximumFileSizeattribute增加大小,但是如何每天停止创建新文件?
Thanks
1 个解决方案
#1
0
You are getting a new file every day because you have set <rollingStyle value="Date"/>
- use <rollingStyle value="Size" />
to only create a new file when the maximum size is reached. You may want to also add a maxSizeRollBackups
entry as well to limit the number of files.
您每天都会收到一个新文件,因为您已设置
#1
0
You are getting a new file every day because you have set <rollingStyle value="Date"/>
- use <rollingStyle value="Size" />
to only create a new file when the maximum size is reached. You may want to also add a maxSizeRollBackups
entry as well to limit the number of files.
您每天都会收到一个新文件,因为您已设置