简体   繁体   English

c#跟踪系统。诊断

[英]c# tracing system.diagnostics

I am using a sync service to sync between compact database and server. 我正在使用同步服务在紧凑型数据库和服务器之间进行同步。 In web.config, i am diagnosing the sync and logging in the file like this: 在web.config中,我正在诊断同步并像这样登录文件:

<system.diagnostics>
   <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
         <listeners>
            <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\MISTYLogs\SYNCService\syncTraces.svclog"></add>
         </listeners>
      </source>
   </sources>
   <switches>
      <add name="SyncTracer" value="3"/>
   </switches>
   <trace autoflush="true">
      <listeners>
         <add name="SyncListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\MISTYLogs\SYNCService\syncinf.txt"/>
      </listeners>
   </trace>
</system.diagnostics>

During sync process, the file size becomes more than one gb. 在同步过程中,文件大小超过1 GB。 I want to restrict the log file size to some limit and after crossing that limit, it should create another log file and so on. 我想将日志文件的大小限制为某个限制,超过该限制后,它将创建另一个日志文件,依此类推。 How to achieve this using configuration settings?? 如何使用配置设置来实现?

Kindly suggest? 请建议?

Look into using the FileLogTraceListener . 研究使用FileLogTraceListener

The FileLogTraceListener class provides automated maintenance capabilities to archive log files as needed, on a daily or per-application basis. FileLogTraceListener类提供了自动维护功能,可以根据需要每天或每个应用程序存档日志文件。 This automatic archival functionality helps reduce the maintenance responsibilities of developers and administrators. 这种自动存档功能有助于减少开发人员和管理员的维护责任。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM