C#日志组件 [英] C# log component
问题描述
大家好,
我正在使用C#和Visual Studio 2005来开发类库。我是b $ b想知道C#中是否有任何内置的日志组件,以便我可以直接使用
而不是从头开始编写?
我也想知道是否确实存在这样的日志组件,如果多个
进程使用内置日志组件打开相同的日志文件来写
log(在我的应用程序中,我想要加载类库的所有进程
DLL有一个公共日志文件),是否有任何竞赛条件的风险
(例如隔行扫描一个进程和另一个进程的日志)?我们需要任何
锁定/同步方法吗?
提前感谢,
George
Hello everyone,
I am using C# and Visual Studio 2005 to develop a class library. I am
wondering whether there are any built-in log component in C# so that I can
utilize directly other than write from scratch?
I am also wondering if there does exist such log component, if multiple
processes using the built-in log component to open the same log file to write
log (in my application, I want all processes which loads the class library
DLL to have a common log file), will there be any risk of racing condition
(e.g. interlacing log of one process and another process)? Do we need any
lock/synchronization approach?
thanks in advance,
George
推荐答案
您可以尝试使用nlog: http://www.nlog -project.org/
关于竞争条件 - 我相信大多数测井组件将代表您担心这个问题。
Marc
You could try nlog: http://www.nlog-project.org/
Regarding the race condition - I believe most logging components will
worry about this on your behalf.
Marc
2007年9月15日星期六11:12:00 +0200,George< Ge *** *@discussions.microsoft.comwrote:
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
大家好,
我正在使用C#和Visual Studio 2005开发一个班级图书馆。我是b $ b想知道C#中是否有任何内置的日志组件,以便我可以直接使用
而不是从头开始编写?
我也想知道是否确实存在这样的日志组件,如果多个
进程使用内置日志组件打开相同的日志文件来写
log(在我的应用程序中,我想要加载类库的所有进程
DLL有一个公共日志文件),是否有任何竞赛条件的风险
(例如隔行扫描一个进程和另一个进程的日志)?我们需要任何
锁定/同步方法吗?
提前感谢,
George
Hello everyone,
I am using C# and Visual Studio 2005 to develop a class library. I am
wondering whether there are any built-in log component in C# so that I can
utilize directly other than write from scratch?
I am also wondering if there does exist such log component, if multiple
processes using the built-in log component to open the same log file to write
log (in my application, I want all processes which loads the class library
DLL to have a common log file), will there be any risk of racing condition
(e.g. interlacing log of one process and another process)? Do we need any
lock/synchronization approach?
thanks in advance,
George
嗨George,
除了Marc的建议外,还有log4net
http://logging.apache.org/log4net/index.html
我还没有尝试过登录文件,但它似乎足够强大,以至于许多日志源不应该是一个问题。
-
快乐的编码!
Morten Wennevik [C#MVP]
Hi George,
In addition to Marc''s suggestion there is also log4net
http://logging.apache.org/log4net/index.html
I haven''t tried logging to file, but it seems robust enough that numerous logging sources should not be a problem.
--
Happy coding!
Morten Wennevik [C# MVP]
Morten Wennevik [C#MVP]写道:
Morten Wennevik [C# MVP] wrote:
2007年9月15日星期六11:12:00 +0200,George< Ge **** @ discussion.microsoft.comwrote:
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
>大家好,
我正在使用C#和Visual Studio 2005来开发类库。我想知道C#中是否有任何内置的日志组件,以便我可以直接使用而不是从头开始编写?
我也想知道是否确实存在这样的日志组件,如果多个进程使用内置的日志组件打开相同的日志文件来写日志(在我的应用程序中,我想要加载类库的所有进程的DLL有一个共同的日志文件),是否有任何竞争条件的风险
(例如隔行扫描一个进程和另一个进程的日志)?我们需要任何
锁定/同步方法吗?
提前感谢,
George
>Hello everyone,
I am using C# and Visual Studio 2005 to develop a class library. I am
wondering whether there are any built-in log component in C# so that I can
utilize directly other than write from scratch?
I am also wondering if there does exist such log component, if multiple
processes using the built-in log component to open the same log file to write
log (in my application, I want all processes which loads the class library
DLL to have a common log file), will there be any risk of racing condition
(e.g. interlacing log of one process and another process)? Do we need any
lock/synchronization approach?
thanks in advance,
George
嗨乔治,
除了Marc的建议外,还有log4net
http://logging.apache.org/log4net/index.html
我没试过记录到文件,但它似乎足够强大,许多日志源不应该是一个问题。
Hi George,
In addition to Marc''s suggestion there is also log4net
http://logging.apache.org/log4net/index.html
I haven''t tried logging to file, but it seems robust enough that numerous logging sources should not be a problem.
我在大型多线程应用程序中使用log4net它工作正常
完美。
HTH,
Andy
-
您可以通过删除下面的NOSPAM部分给我发电子邮件:
xm ***** *****@gmxNOSPAM.net
这篇关于C#日志组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!