记录应用程序阻止不从工作站记录到文件

时间:2016-05-15 05:23:00

标签: c# logging

这是我的Microsoft Enterprise日志记录配置。 这不是从客户端工作站记录的。它从服务器正确记录。 什么样的文件夹C:\ temp \ logs \ PFService.log权限应该从工作站登录。

<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging"/>
</configSections>
     <loggingConfiguration name="Logging Application Block" tracingEnabled="false" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
        <listeners>
          <clear />
          <add source="Web Server" formatter="Text Formatter" log="" machineName="." listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" name="Event Log Destination"/>
          <add fileName="c:\temp\logs\PFService.log" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Increment" rollSizeKB="96" rollInterval="Day" name="Rolling File Destination"/>
        </listeners>

        <formatters>
          <clear />
          <add template="{timestamp(local:yyyy-MM-dd HH:mm:ss.fff)} {category} - {title}: {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging" name="Text Formatter"/>
        </formatters>
        <logFilters>
          <clear />
          <add categoryFilterMode="AllowAllExceptDenied" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging" name="Category"/>
          <add enabled="true" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging" name="LogEnabled Filter"/>
        </logFilters>
        <categorySources>
          <add switchValue="All" name="Debug">
            <listeners>
              <add name="Rolling File Destination"/>
            </listeners>
          </add>
          <add switchValue="All" name="Exceptions">
            <listeners>
              <add name="Rolling File Destination"/>
            </listeners>
          </add>
          <add switchValue="All" name="General">
            <listeners>
              <add name="Rolling File Destination"/>
            </listeners>
          </add>
        </categorySources>
        <specialSources>
          <allEvents switchValue="All" name="All Events"/>
          <notProcessed switchValue="All" name="Unprocessed Category"/>
          <errors switchValue="All" name="Logging Errors &amp; Warnings">
            <listeners>
              <add name="Event Log Destination"/>
            </listeners>
          </errors>
        </specialSources>
      </loggingConfiguration>


 public static void Log(string _Title, string _Message, string _Category)
        {
            LogEntry logEntry = new LogEntry();

            logEntry.Title = _Title;
            logEntry.Message = _Message;
            logEntry.Categories.Add(_Category);

            Logger.Write(logEntry);
        }

0 个答案:

没有答案