473,791 Members | 3,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# log component

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
Sep 15 '07
20 5727
On Sat, 15 Sep 2007 17:28:02 +0200, George <Ge****@discuss ions.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****@discuss ions.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]
Sep 15 '07 #11
Thanks Morten,
I have found one,TextWriterT raceListener.

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****@discuss ions.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****@discuss ions.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]
Sep 15 '07 #12
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**********@gm xNOSPAM.net
Sep 15 '07 #13
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
Sep 15 '07 #14
Thanks Arne,
I want to use something simple. :-)

Do you have any experiences of TextWriterTrace Listener?

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
Sep 16 '07 #15
Thansk Andy,
I would like to try some function which is Microsoft built-in. :-)
Do you have any experiences of using TextWriterTrace Listener?

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**********@gm xNOSPAM.net
Sep 16 '07 #16
Thanks Andy,

I want to use some Microsoft built-in function. :-)

Do you have any experiences of using TextWriterTrace Listener?

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**********@gm xNOSPAM.net
Sep 16 '07 #17
George wrote:
Thansk Andy,
I would like to try some function which is Microsoft built-in. :-)
Do you have any experiences of using TextWriterTrace Listener?

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**********@gm xNOSPAM.net
Sep 16 '07 #18
George wrote:
I want to use something simple. :-)

Do you have any experiences of TextWriterTrace Listener?

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
Sep 16 '07 #19
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.comwro te in message
news:op.tyox14b idj93y5@ubuan.. .
On Sat, 15 Sep 2007 11:12:00 +0200, George
<Ge****@discuss ions.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]
Sep 17 '07 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1790
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. So you purchase a .NET charting component, design the app, and deliver it to the customer. One year later, the customer comes back and says, "There's a bug in your app. The application crashes when I do such and such to the chart." I start...
4
8053
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 differences?
2
1762
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 a component when another component is destroyed ? I have a managed component called P. Let us say that C is another managed component. If on P I have: __property C * get_CComp(); __property void set_CComp(C *);
0
1454
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 the 2nd property is a strongly typed collection class (myCollectionProperty). The collection contains a simple class (myCustomClass) which has 1 text property (TextProperty).
2
2446
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 fine. However, when attempting to assing default values as designtime in the propertygrid, nothing is working on the class object. I know that I am doing it wrong, any ideas what it is? Thanks in advance
1
8709
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 Framework are said to have an element type. http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
122
7438
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 outside of that class. This structured way allows visual tools to host components, and allows programmers to build applications and libraries visually in a RAD environment. The Java language has JavaBeans as its component model which allows Java...
7
2230
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 example if I drop a component on Form1 & Form2 and that component has a property called Server, at design time I would like to be able to assign the global component to the Server property. I'm sure I'm asking for way too much...
11
1869
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. I'm calling Marshal.ReleaseComObject after I make each call. public NotifyResponse Notify(NotifyRequest reqMessage) { try {
0
5357
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,
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.