开发者

How can I get my logger to overwrite old log file in C# using Enterprise Library?

Using Enterprise Library 3.1, I have a logger that, once it reaches its "r开发者_开发技巧ollSizeKB" refuses to overwrite the log file. What am I missing?

<listeners>
  <add formatter="Text Formatter"
       listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
       traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
       rollSizeKB="1"
       rollInterval="None"
       rollFileExistsBehavior="Overwrite"           
       name="Formatted EventLog TraceListener"
       fileName="logfile.log"/>
</listeners>

For my testing purposes, I have the rollSizeKB purposely small. Once logfile.log hits 1KB, it stops writing to the file and will not overwrite it. What am I missing?


I'm not 100% sure what is going on but this sounds like it could be a permission problem.

Can you check the permissions on the folder that logfile.log is in? As a check: if there are no Deny permissions set, then grant Everyone Full Control on the folder and rerun your program to see if that makes a difference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜