473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Extend .NET Class, or Write a New Class

I'm implementing logging via the TraceSource class and related TraceSwitch
and TraceListeners classes.

The TextWriterTraceListener does much of what I need. But it does not roll
the log over at some max size, and is missing a couple of other feaures.

It appears that I have two options for getting the behavior I want:
1. Extend the TextWriterTraceListener (it isn't sealed), adding the features
I want in my derived class.
2. Write my own custom trace listener, extending the base TraceListener
class. I would then proceed to duplicate basically all of the functionality
in the TextWriterTraceListener and add the new functionality I want.

My tendency is to go with #1 above and extend the existing
TextWriterTraceListener class.

Are there any good reasons to NOT do that? Would it be better for me to
write a new class instead? (and yes, I'm aware of log4net, but don't want to
go that route for now).

I appreciate your thoughts on this.
Sep 20 '07 #1
1 1922
Jeremy S. wrote:
I'm implementing logging via the TraceSource class and related
TraceSwitch and TraceListeners classes.

The TextWriterTraceListener does much of what I need. But it does not
roll the log over at some max size, and is missing a couple of other
feaures.

It appears that I have two options for getting the behavior I want:
1. Extend the TextWriterTraceListener (it isn't sealed), adding the
features I want in my derived class. 2. Write my own custom trace
listener, extending the base TraceListener class. I would then
proceed to duplicate basically all of the functionality in the
TextWriterTraceListener and add the new functionality I want.
3. use Log3Net and spend the time you save with that on nice things in
life :)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Sep 20 '07 #2

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

Similar topics

10
by: Jerzy Karczmarczuk | last post by:
Gurus, before I am tempted to signal this as a bug, perhaps you might convince me that it should be so. If I type l=range(4) l.extend() l gives , what else... On the other hand, try
2
by: Boobie | last post by:
I switched to using this function to create element: ---------------------------------------------------- function elem(name, attrs, style, text) { var e = document.createElement(name); if...
3
by: James | last post by:
Hi, I have two classes, a base clase ItemType and a class which inherits from it called Item. During the runtime of my program, I create an instance of ItemType, then later, I would like to...
3
by: Kevin | last post by:
Hello, I do not have experience extending a vb.net class and would like some assistance. I want to extend the Microsoft.Solutions.Framework.Address class to include a phone number. How do i do...
4
by: Coder | last post by:
Hi, Running into an issue. I am creating a base class. This base class has a "State" property of type "States" which is a locally defined enum type. The issue is this...the derived class...
2
by: abcd | last post by:
I have a class which extends 'file' .... class MyFile(file): def __init__(self, fname, mode='r'): file.__init__(self, fname, mode) def write(self, str): print "writing a string"...
3
by: jacobstr | last post by:
I've noticed Object.extend used in a few different ways and I'm having trouble distinguishing why certain usages apply to a given situation. On line 804 Ajax.Base is defined as follows: ...
6
by: Ioannis Papadopoulos | last post by:
I would like to extend the functionality of all streams in C++ so I can do some fancy stuff like redirecting the streams on the fly. I don't want to reimplement the whole stream support in C++...
7
by: cbmeeks | last post by:
Hope I'm using the right terminology. Anyway, say I have a class like: class Animal { public double GetValues() {......} public void FilterBy(string text); {......}
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.