Trace file isn't being created even though TraceEvent is called?

后端 未结 2 1899
后悔当初
后悔当初 2020-12-12 07:48

Objective

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

2条回答
  •  独厮守ぢ
    2020-12-12 08:05

    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.)

提交回复
热议问题