473,320 Members | 1,829 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,320 software developers and data experts.

how to write a log file

a
I'm going to iterate over the rows of a datagrid.
The contents of a column are web addresses that I'm going to use in HTTP
requests.
Since this will most likely crash at some point, I'd like to write some sort
of log that would help me see where it stops working, rather than having to
go in manually and look at the downloaded files.

Anyone have any suggestions as to a good way to go about this, or any
favorite articles on the subject?

Thanks
Nov 17 '05 #1
2 1352
Using System.Diagnostics;

EventLog logger= new EventLog();
logger.Source = "MySource";
logger.Log = "MyLog";
if(!EventLog.SourceExists("MySource"))
{EventLog.CreateEventSource("MySource", "MyLog"); }

try
{
//Code you wish to try
}
catch(Exception ex)
{
this.logger.WriteEntry("ex.Message");
}

"a" wrote:
I'm going to iterate over the rows of a datagrid.
The contents of a column are web addresses that I'm going to use in HTTP
requests.
Since this will most likely crash at some point, I'd like to write some sort
of log that would help me see where it stops working, rather than having to
go in manually and look at the downloaded files.

Anyone have any suggestions as to a good way to go about this, or any
favorite articles on the subject?

Thanks

Nov 17 '05 #2
Remove the quotes from around ex.Message, though. ;-)

On Wed, 1 Jun 2005 00:46:05 -0700, CodeRazor
<Co*******@discussions.microsoft.com> wrote:
Using System.Diagnostics;

EventLog logger= new EventLog();
logger.Source = "MySource";
logger.Log = "MyLog";
if(!EventLog.SourceExists("MySource"))
{EventLog.CreateEventSource("MySource", "MyLog"); }

try
{
//Code you wish to try
}
catch(Exception ex)
{
this.logger.WriteEntry("ex.Message");
}

"a" wrote:
I'm going to iterate over the rows of a datagrid.
The contents of a column are web addresses that I'm going to use in HTTP
requests.
Since this will most likely crash at some point, I'd like to write some sort
of log that would help me see where it stops working, rather than having to
go in manually and look at the downloaded files.

Anyone have any suggestions as to a good way to go about this, or any
favorite articles on the subject?

Thanks


Nov 17 '05 #3

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

Similar topics

1
by: Ellixis | last post by:
Hello, How can I use fwrite() and fseek() in order to write data in the middle (or anywhere else) of a file without overwriting existing data ? People told me that I should load the file into...
5
by: Just Me | last post by:
Using streams how do I write and then read a set of variables? For example, suppose I want to write into a text file: string1,string2,string3 Then read them later. Suppose I want to write...
6
by: sambuela | last post by:
How can I write message to the file located in the wwwroot directory? It seems that IIS protect these files. Let make me cannot do the I/O writing sucessfully. I try to open file's write...
2
by: ykgoh | last post by:
Hi. I've a problem of being able to create and remove a directory but unable to write a file inside the created directory for some strange reason. I suspect that this problem could be vaguely...
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
1
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example,...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
6
by: globalrev | last post by:
i ahve a program that takes certain textsnippets out of one file and inserts them into another. problem is it jsut overwrites the first riow every time. i want to insert every new piece of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.