如何指示EventLogTraceListener在特定的日志中创建

Mic*_*elD 7 .net c# config listeners event-log

调用Trace.WriteLine时,以下侦听器将创建一个事件条目.如果源不存在,他将在默认日志通道"应用程序"中创建它.我想指定另一个默认的日志频道,但搜索45分钟后,我似乎找不到解决方案.有任何想法吗?

<configuration>   
  <system.diagnostics>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="myListener"               
          type="System.Diagnostics.EventLogTraceListener"
          initializeData="Source">          
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Bri*_*lph 3

不确定是否可以通过配置。

尽管 EventLogTraceListener 确实接受不同的事件日志作为构造函数中的参数。不幸的是,该类是密封的,因此您不能简单地从它派生并为构造函数传递不同的值。

尽管您可以遵循这种方法并构建您自己的类(看起来相当简单)。然后在您的配置中引用该类型。 http://weblogs.asp.net/psteele/archive/2006/02/23/438936.aspx