473,503 Members | 2,259 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 4317
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 TextWriterTraceListener 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
2259
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
7188
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"....
1
1217
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...
4
2593
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...
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...
0
1038
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...
46
24130
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
0
1098
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...
0
7093
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
7291
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,...
1
7012
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...
0
7468
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...
1
5023
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...
0
4690
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...
0
3180
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...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
748
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.