473,804 Members | 4,518 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 4368
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
2281
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
7208
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
1230
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
2602
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
1053
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
24282
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
0
1127
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
9706
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
9579
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
10332
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
10320
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
10077
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...
1
7620
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
6853
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
5521
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...
1
4299
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

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.