473,782 Members | 2,513 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 #1
20 5726
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

Sep 15 '07 #2
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 15 '07 #3
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.
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**********@gm xNOSPAM.net
Sep 15 '07 #4
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****@discuss ions.microsoft. comwrote in message
news:00******** *************** ***********@mic rosoft.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

Sep 15 '07 #5
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*****@sbcglo bal.netwrote in message
news:u7******** **********@news svr11.news.prod igy.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****@discuss ions.microsoft. comwrote in message
news:00******** *************** ***********@mic rosoft.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


Sep 15 '07 #6
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

Sep 15 '07 #7
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]
Sep 15 '07 #8
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****@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.
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**********@gm xNOSPAM.net
Sep 15 '07 #9
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****@discuss ions.microsoft. comwrote in message
news:00******** *************** ***********@mic rosoft.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


Sep 15 '07 #10

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

Similar topics

12
1789
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
1453
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
8706
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
7432
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
2229
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
1868
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
5356
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
9479
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,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
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,...
1
7492
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
6733
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();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
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
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
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.