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 20 5686
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
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
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
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] wrote:
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
>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
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.
I'm using log4net in a large multi threaded application and it works
perfect.
HTH,
Andy
--
You can email me by removing the NOSPAM parts below: xm**********@gmxNOSPAM.net
i wrote my own..logging....multi threaded service
1st thread starts the logging...all other services open and share the
log....
in my log class,
i wrote...
1. if can't log to sq db , 2 if i cant write to text file , 3 if that fails
in my app.config
1. i have sql serve connection string for log (table)
2. path and file name for log files (text files)
if you want to see the class....let me know
its work in progress..since im only about 1 year with c# net...all other
experience was win32, languages
DaveP
DaveP
write to event log
"George" <Ge****@discussions.microsoft.comwrote in message
news:00**********************************@microsof t.com...
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
i typed the last comment all messed up
what i actually do is
1 try to write to my errorsdb..log table
if fails
2. try to write to app defined text file log
if that fails
3 try to write to machine event log
if all 3 of the above fails... well somthing is really broken
i never write to all 3 at once....some people do...
i just think that is a waist of time and resources
DaveP
"DaveP" <dv*****@sbcglobal.netwrote in message
news:u7******************@newssvr11.news.prodigy.n et...
>i wrote my own..logging....multi threaded service
1st thread starts the logging...all other services open and share the
log....
in my log class,
i wrote...
1. if can't log to sq db , 2 if i cant write to text file , 3 if that
fails
in my app.config
1. i have sql serve connection string for log (table)
2. path and file name for log files (text files)
if you want to see the class....let me know
its work in progress..since im only about 1 year with c# net...all other
experience was win32, languages
DaveP
DaveP
write to event log
"George" <Ge****@discussions.microsoft.comwrote in message
news:00**********************************@microsof t.com...
>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
Thanks Marc,
You mean Microsoft .Net has no built-in log function?
regards,
George
"Marc Gravell" wrote:
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
Thanks Morten,
You mean Microsoft .Net itself does not provide log function? I only need to
log to a local file.
regards,
George
"Morten Wennevik [C# MVP]" wrote:
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
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
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]
Thanks Andy,
Does it provide function to keep log size to some threshold? I do not want
the log file too big. Thanks.
regards,
George
"Andreas Mueller" wrote:
Morten Wennevik [C# MVP] wrote:
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
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
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.
I'm using log4net in a large multi threaded application and it works
perfect.
HTH,
Andy
--
You can email me by removing the NOSPAM parts below: xm**********@gmxNOSPAM.net
Thanks for your kindness DaveP!
I have only used for C# for half a year. If possible, could I learn your
code please? From your description, it looks like what I am looking for.
regards,
George
"DaveP" wrote:
i wrote my own..logging....multi threaded service
1st thread starts the logging...all other services open and share the
log....
in my log class,
i wrote...
1. if can't log to sq db , 2 if i cant write to text file , 3 if that fails
in my app.config
1. i have sql serve connection string for log (table)
2. path and file name for log files (text files)
if you want to see the class....let me know
its work in progress..since im only about 1 year with c# net...all other
experience was win32, languages
DaveP
DaveP
write to event log
"George" <Ge****@discussions.microsoft.comwrote in message
news:00**********************************@microsof t.com...
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
On Sat, 15 Sep 2007 17:28:02 +0200, George <Ge****@discussions.microsoft.comwrote:
Thanks Morten,
You mean Microsoft .Net itself does not provide log function? I only need to
log to a local file.
regards,
George
"Morten Wennevik [C# MVP]" wrote:
>On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
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 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]
Not really. The closes thing is the Trace and Debug classes. But you need to write some code to make them good logging classes.
--
Happy coding!
Morten Wennevik [C# MVP]
Thanks Morten,
I have found one,TextWriterTraceListener. http://msdn2.microsoft.com/en-us/lib...elistener.aspx
After reading through this page, I am still a little confused about how to
use it step by step. Do you have a tutorial?
regards,
George
"Morten Wennevik [C# MVP]" wrote:
On Sat, 15 Sep 2007 17:28:02 +0200, George <Ge****@discussions.microsoft.comwrote:
Thanks Morten,
You mean Microsoft .Net itself does not provide log function? I only need to
log to a local file.
regards,
George
"Morten Wennevik [C# MVP]" wrote:
On Sat, 15 Sep 2007 11:12:00 +0200, George <Ge****@discussions.microsoft.comwrote:
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
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]
Not really. The closes thing is the Trace and Debug classes. But you need to write some code to make them good logging classes.
--
Happy coding!
Morten Wennevik [C# MVP]
George wrote:
Thanks Andy,
Does it provide function to keep log size to some threshold? I do not want
the log file too big. Thanks.
Yes, you can limit the size and also let the file appender roll. You can
specify multiple appenders, e.g. for sending your log output to the
console or a trace window.
It's very simple to configure and has a good performance.
HTH,
Andy
--
You can email me by removing the NOSPAM parts below: xm**********@gmxNOSPAM.net
George wrote:
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?
You can get a "Logging Application Block" in "Enterprise Library"
from Microsoft.
But I would recommend log4net.
Arne
Thanks Arne,
I want to use something simple. :-)
Do you have any experiences of TextWriterTraceListener? http://msdn2.microsoft.com/en-us/lib...elistener.aspx
Is it thread and application safe?
regards,
George
"Arne Vajhøj" wrote:
George wrote:
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?
You can get a "Logging Application Block" in "Enterprise Library"
from Microsoft.
But I would recommend log4net.
Arne
Thansk Andy,
I would like to try some function which is Microsoft built-in. :-)
Do you have any experiences of using TextWriterTraceListener? http://msdn2.microsoft.com/en-us/lib...elistener.aspx
Does it provide any function of limit the size of log? If it does not
provide the function, are there any way to implement the size limit function
application code?
regards,
George
"Andreas Mueller" wrote:
George wrote:
Thanks Andy,
Does it provide function to keep log size to some threshold? I do not want
the log file too big. Thanks.
Yes, you can limit the size and also let the file appender roll. You can
specify multiple appenders, e.g. for sending your log output to the
console or a trace window.
It's very simple to configure and has a good performance.
HTH,
Andy
--
You can email me by removing the NOSPAM parts below: xm**********@gmxNOSPAM.net
Thanks Andy,
I want to use some Microsoft built-in function. :-)
Do you have any experiences of using TextWriterTraceListener? http://msdn2.microsoft.com/en-us/lib...elistener.aspx
Does it provide function of limit the size of log? If no such function
provided, how to implement from application code?
regards,
George
"Andreas Mueller" wrote:
George wrote:
Thanks Andy,
Does it provide function to keep log size to some threshold? I do not want
the log file too big. Thanks.
Yes, you can limit the size and also let the file appender roll. You can
specify multiple appenders, e.g. for sending your log output to the
console or a trace window.
It's very simple to configure and has a good performance.
HTH,
Andy
--
You can email me by removing the NOSPAM parts below: xm**********@gmxNOSPAM.net
George wrote:
Thansk Andy,
I would like to try some function which is Microsoft built-in. :-)
Do you have any experiences of using TextWriterTraceListener?
http://msdn2.microsoft.com/en-us/lib...elistener.aspx
Does it provide any function of limit the size of log? If it does not
provide the function, are there any way to implement the size limit function
application code?
No, I have never used it. From looking at the doc, I don't see a
limitation for the file size, too
Perhaps it is an option for you to implement a custom trace listener.
All you have to do (sounds simple :-) )is to derive from TraceListener
and implement the desired methods. You have to to the "ringbuffer"
writing yourself.
If you want to stick to MS stuff, how about the enterprise logging
application block?
HTH,
Andy
--
You can email me by removing the NOSPAM parts below: xm**********@gmxNOSPAM.net
George wrote:
I want to use something simple. :-)
Do you have any experiences of TextWriterTraceListener?
http://msdn2.microsoft.com/en-us/lib...elistener.aspx
Is it thread and application safe?
I have not tried it.
The link you gave say:
Thread Safety
Any public static (Shared in Visual Basic) members of this type
are thread safe. Any instance members are not guaranteed to be
thread safe.
Arne
The bank where I work as a software architect uses Log4Net extensively and
it's very reliable and simple to use.
--
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:op.tyox14bidj93y5@ubuan...
On Sat, 15 Sep 2007 11:12:00 +0200, George
<Ge****@discussions.microsoft.comwrote:
>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
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]
On Sep 15, 5:12 am, George <Geo...@discussions.microsoft.comwrote:
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
I'm a big fan of the System.Diagnostics tracing classes. Typical
usage is to instantiate the TraceListener derived class for the
storage medium you want to you use (e.g., EventLogTraceListener to
write to the windows event log, TextWriterTraceListener to write to a
file) then conditionally trace based on a TraceSwitch.
You can automatically configure trace switches and listeners from your
app.config file.
A few caveats: TextWriterTraceListener uses exclusive access to the
file so you'll have to use one of its other constructors to specify
shared access, you'll have to handle synchronization yourself, be
careful with the EventLogTraceListener as it can easily fill up the
windows event log in a space constrained situation.
Code-wise what you'll end up with is lots of statements like:
Trace.WriteLineIf(switch.TraceInfo, "....")
where you set the value of the trace switch in your app config file,
instantiate it and add listeners via config file or programmatically
to your listener collection. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chien Lau |
last post by:
I had a situation occur today that's happened a number of times before
and I'd like to get your take on it:
Imagine... You're developing a WinForms app for a client that includes
the use charts....
|
by: orangepic333 |
last post by:
Could someone tell me what's the difference between the two?
Is it that a class is used within an OO language while a component can
be exported between OO languages?
Are there other...
|
by: Edward Diener |
last post by:
How does one specify in a component that a property is a pointer to another
component ? How is this different from a property that is actually an
embedded component ? Finally how is one notified in...
|
by: Jordan Bowness |
last post by:
I make a similar post in another newsgroup, but this example is
simplified somewhat.
I have a component (cmpMyComponent) with 2 properties. The 1st property
is a string value (Description) and...
|
by: AMDRIT |
last post by:
Hello everyone,
I have created a custom component and one of its properties is a class
object with it's own properties. During runtime, I can assign values to the
class object properties just...
|
by: Rob Griffiths |
last post by:
Can anyone explain to me the difference between an element type and a
component type?
In the java literature, arrays are said to have component types, whereas
collections from the Collections...
|
by: Edward Diener No Spam |
last post by:
The definition of a component model I use below is a class which allows
properties, methods, and events in a structured way which can be
recognized, usually through some form of introspection...
|
by: Joe |
last post by:
Is it possible to have a component which is global to the entire
application? I need to have a single component act sort of like a server
which components in any of the forms can access.
For...
|
by: BillGatesFan |
last post by:
I have a web service which calls a .NET queued serviced component in
COM+. I turned statistics on for the component. I call the component
10 times, 10 objects get created but they do not go away....
|
by: bharathreddy |
last post by:
In .Net COM+ components are referred to as serviced components,
Namespace: System.EnterpriseServices;
Advantage of Serviced Components:
object pooling,
database connection pooling,
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |