473,657 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debug.Write into a file ???

Hi,

I am wanting to put some simple logging into my .net app. The basic features
will be that errors get logged to a file and that there will be a
configuration flag to enable more detailed logging. It must be simple to
enable the detailed output in the live application.

I have used Debug.Write() but this seems to come out only on the output
window in the IDE - is there a way of configuring this to go into a file? I
also saw there is Trace.Write() but it seems that for this I have to
implement my own listener application to listen to the trace output.

Is it easy to make either of these do what I want or should I roll my own
logging code? I know that there is a port of log4j caled log4net but my app
is really not big enough to warrant this level of sophistication. At the
moment I am not after being able to have different levels of logging for
different components.

Thanks in advance for any advice

Andy
Jul 21 '05 #1
2 4353
Andy Fish wrote:
Hi,

I am wanting to put some simple logging into my .net app. The basic
features will be that errors get logged to a file and that there will be a
configuration flag to enable more detailed logging. It must be simple to
enable the detailed output in the live application.

I have used Debug.Write() but this seems to come out only on the output
window in the IDE - is there a way of configuring this to go into a file?
I also saw there is Trace.Write() but it seems that for this I have to
implement my own listener application to listen to the trace output.

Any .Net app can set up Trace.Listeners to handle logging/debug messages.

The great thing about it is a Listener can be many things.

It can be a text file -- yes -- but, you can also write directly to the OS
Event log -- for example, you could write to the Windows Application Event
log -- OR, you can create your own Event type such as MyApp -- which can be
viewed from Event Viewer.

There's a great, cheap, e-book called 'Tracing and Logging in .NET' that is
available as a PDF from Amazon. I suggest you read it.


Is it easy to make either of these do what I want or should I roll my own
logging code? I know that there is a port of log4j caled log4net but my
app is really not big enough to warrant this level of sophistication. At
the moment I am not after being able to have different levels of logging
for different components.

Thanks in advance for any advice

Andy


--
w:4

Jul 21 '05 #2
There are a couple of subclasses of TraceListener provided in the framework and TextWriterTrace Listener does what you want. You need to add some entries to app.config to wire it up.

However bear in mind that this imposes quite an overhead. EIF is the recommended way to go because its much lower overhead.

Also there is an logging application block
http://msdn.microsoft.com/library/de...ml/Logging.asp

If you want a plug & go solution.

Niroo

"Andy Fish" wrote:
Hi,

I am wanting to put some simple logging into my .net app. The basic features
will be that errors get logged to a file and that there will be a
configuration flag to enable more detailed logging. It must be simple to
enable the detailed output in the live application.

I have used Debug.Write() but this seems to come out only on the output
window in the IDE - is there a way of configuring this to go into a file? I
also saw there is Trace.Write() but it seems that for this I have to
implement my own listener application to listen to the trace output.

Is it easy to make either of these do what I want or should I roll my own
logging code? I know that there is a port of log4j caled log4net but my app
is really not big enough to warrant this level of sophistication. At the
moment I am not after being able to have different levels of logging for
different components.

Thanks in advance for any advice

Andy

Nov 22 '05 #3

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

Similar topics

0
2274
by: modemer | last post by:
Anybody knows if it is possible to use gdb/dbx to debug .pc file instead of generated .c file? Thanks
1
7198
by: Nitin | last post by:
i dont know , what's the reson of this, but if i complile my solution in release mode , it works , but give buid error in Debug mode -- "Unexpected error creating debug information file .pdb". Project is on .net 1.0 framework. Error came after i installed framework 2.0 from net. but now i uninstalled it. but facing same problem , i have also tried repair from VS.net setup, pls tell me if anyone get solution of this..
1
1223
by: Hans [DiaGraphIT] | last post by:
Hi! When developing a windows application I sometimes recieve a popup wnidow with an exception message. (telling me somthing about JIT... with following error message) When this exceptions occurs I whish that the applications should save it to a file, as a log. How do I do that, or where do I find info about it?
4
2599
by: Laurence Nuttall | last post by:
I have opened the Immediate window, but my debug.write and debug.writeline results are nowhere to be found in the immdediate window. Does anyone know where ther results of the debug.write and debug.writeline go? Thanks in Advance, Laurence Nuttall
1
351
by: Andy Fish | last post by:
Hi, I am wanting to put some simple logging into my .net app. The basic features will be that errors get logged to a file and that there will be a configuration flag to enable more detailed logging. It must be simple to enable the detailed output in the live application. I have used Debug.Write() but this seems to come out only on the output window in the IDE - is there a way of configuring this to go into a file? I also saw there is...
0
1043
by: Chris Lane | last post by:
Hi, Did this change in Visual Studio 2005? Visual Studio 2003 didn't create a debug symbol file once the solution and project were changed to be built for release. I did notice the same difficult problem in 2005 that was in 2003 and that is getting the build for Release properties to stick on the solution and project. In my project I have verified that both the solution and project are set to
46
24210
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
0
1119
by: Swan | last post by:
Can anyone plz tell me,Can I write file on server using binary access,or it is only to write on local?(Actually I am creating OCX for Http File Upload Control in VB using API's.So for that I need to raed file from local and write it to server.) Thanking you!
0
8324
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
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
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...
0
5642
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
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.