使用线程创建跟踪日志文件 [英] Creating trace log file using threading

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

问题描述




我想创建一个跟踪日志文件.就像整个项目中每个函数的入口点和出口点一样,我想在文本文件中写一些文本.在我的应用程序中,我正在使用线程来执行其他一些任务,但是由于这个线程,我们无法在该跟踪日志文件上进行写操作.它给消息类似您不能使用跟踪日志文件,因为该跟踪日志文件正在被另一个处理器使用"这样的消息.谁能告诉我这个问题的解决办法.


谢谢

Hi,


I want to create a trace log file. Like in the whole project in every function,s entry point and at the exit point, I want to write some text in a text file. And in my application I am using a threading to do some other task, but due to this thread we are unable to write on that trace log file. It gives the message somethig like ''you can not use trace log file because that trace log file is being used by another processor''. Can anybody tell me the solution of this problum.


Thanks

推荐答案

使用类似 Nlog [
Use logging library like Nlog[^]. It will handle synchronization for you.



这样的选项很少
log4net [ ^ ]
nlog [ ^ ]
日志记录应用程序块 [
.NET日志记录框架
[ ^ ]
跟踪与记录以及如何进行是否适合log4net?
[ ^ ]
There are few options like

log4net[^]
nlog[^]
The Logging Application Block[^]

These tools are designed for logging and tracing. You can use one of them.
Some other links:

.NET logging framework
[^]
Tracing versus Logging and how does log4net fit in?
[^]


使用 ^ ],用于解决线程同步问题并强制代码块一次执行一个线程.
Use lock statement[^] for solving Thread Synchronization issues and force the code block to execute one thread at a time.


这篇关于使用线程创建跟踪日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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