跟踪文件不被创建即使TraceEvent叫? [英] Trace file isn't being created even though TraceEvent is called?

查看:189
本文介绍了跟踪文件不被创建即使TraceEvent叫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标



使用 System.Diagnostics程序进行跟踪。虽然我已经使用 log4net的和其他记录解决方案,我只得到跟踪与 System.Diagnostics程序工作感兴趣。



问题



尽管我发出 TraceEvent 不被任何地方创建的文件。



应用信息



我有一个应用程序的托管一些WF服务。该业务之一是一个状态机的初始状态,看起来像这样:





的LogMessage 自定义活动也非常直截了当。它接收四个基本参数:





定义了 TraceSource 为一个变量:



< IMG SRC =htt​​p://i.stack.imgur.com/cY3Fk.pngALT =的LogMessage TraceSource变量>



,然后简单地调用 TraceEvent





配置



此配置 TraceSource 的TraceListener 如下:

 < System.Diagnostics程序> 
<跟踪自动冲洗=真/>
<来源和GT;
<信源名称=日志switchValue =所有>
<&听众GT;
<添加名称=文件TYPE =Microsoft.VisualBasic.Logging.FileLogTraceListener,Microsoft.VisualBasic程序,版本= 10.0.0.0,文化=中性公钥= b03f5f7f11d50a3a
BaseFileName =gsf_workflows。 TXT
DiskSpaceExhaustedBehavior =ThrowException
位置=自定义
CustomLocation =D:\Log
MAXFILESIZE =81920000
LogFileCreationSchedule =LogFileCreationScheduleOption 。每日/>
< /听众>
< /源>
< /来源>
< /system.diagnostics>


解决方案

FYI大家绊脚石此页面上..



如果他们缺少FileLogTraceListener不会创建文件夹。



FileLogTraceListener不会绕过安全,您的进程标识需要创建+修改目标文件夹的权限。



这是坏表为目标的可执行文件夹,这往往取决于主机上(例如,在IIS快递你是不是写的同一位置devenv的,也不是托管网络应用程序。当写入时)一个建议是改变那不是ExecutableLocation你可能想选择自定义并指定特定的路径(如X:\logfiles)



作家刷新到磁盘时,他们的内部缓冲区填满,如果我没有记错的默认缓冲区大小为8KB。这不是跟踪侦听器的一个方面,但潜在的文件流写入到。



最后,如果你不需要的形式和FileLogTraceListener的功能,而不是考虑跟踪到事件日志(有这种侦听器),因为这可能对其他开发者和非开发者更容易获得(如OPS工程师,第三方监控工具,等等。)


Objective

Use System.Diagnostics to perform tracing. Though I have used log4net and other logging solutions, I am only interested in getting tracing to work with System.Diagnostics.

Problem

Even though I'm issuing the TraceEvent the file is not being created anywhere.

Application Information

I have an application that's hosting some WF services. One of the services is a state machine with an initial state that looks like this:

the LogMessage custom activity is also very straight forward. It receives four basic parameters:

defines the TraceSource as a variable:

and then simply calls TraceEvent:

Configuration

The configuration for this TraceSource and TraceListener is as follows:

  <system.diagnostics>
    <trace autoflush="true"/>
    <sources>
      <source name="log" switchValue="All">
        <listeners>
          <add name="file" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               BaseFileName="gsf_workflows.txt"
               DiskSpaceExhaustedBehavior="ThrowException"
               Location="Custom"
               CustomLocation="D:\Log"
               MaxFileSize="81920000"
               LogFileCreationSchedule="LogFileCreationScheduleOption.Daily"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

解决方案

FYI for everyone stumbling on this page..

FileLogTraceListener will not create folders if they are missing.

FileLogTraceListener will not bypass security, your process identity will need create+modify permissions on the target folder.

It's "bad form" to target the executable folder, this tends to change depending on the host (for example, when writing under IIS Express you aren't writing to the same location as DevEnv, nor the hosted web app.) One suggestion is that instead of "ExecutableLocation" you may want to opt for "Custom" and specify a particular path (such as X:\logfiles)

Writers flush to disk when their internal buffers fill, if memory serves me the default buffer size is 8KB. This is not a facet of trace listeners, but the underlying file stream it writes to.

Lastly, if you do not need the form and function of FileLogTraceListener, instead consider tracing to the EventLog (there is a listener for this) as this may be more accessible to other devs and non-devs (such as ops engineers, third party monitoring tools, etc.)

这篇关于跟踪文件不被创建即使TraceEvent叫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆