473,324 Members | 2,248 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,324 software developers and data experts.

Writing to a log file with in an aspx file.

Hello,

I have been digging into writing into a file with the dot net
framework. There is a lot of information on it. I have a web
application and I want to write to a log file when an exception is
encountered. Writing to this file is not mission critical. Therefore
it seems like synchronous writing would be ok. I am looking for
something simple in what seems to be a complex topic. There are
fileinfos, streams, filesteams etc etc.

Does anyone have any advice on which of these objects to start with?
They all seem like overkill for what I want to do.

I want to create/open a file to a specific path like c:\logs\error.log
and write a variable of string class into it. I don't need to read
it.

Thanks,

HH
Nov 18 '05 #1
2 2885
My Dear friend,

You are having the same problem I had when I switched from VB to VB.NET.
It is not really overkill. It looks complex at first glance, but once you
get used to the new helper classes you will be fine.

What I suggest you do is:

1) Make yourself a small LogWriter Class that implements simple methods like
"WriteToLog", etc.

- OR -

2) Simply write the code to append a line to a certain file:

Dim w As StreamWriter = system.io.File.AppendText("logfile.txt")
w.WriteLine("Your hard drive is dying >:P ")
w.Flush() 'Update underlying file
w.Close()

Good Luck!
"JuneCleaver" <h_************@yahoo.com> wrote in message
news:76*************************@posting.google.co m...
Hello,

I have been digging into writing into a file with the dot net
framework. There is a lot of information on it. I have a web
application and I want to write to a log file when an exception is
encountered. Writing to this file is not mission critical. Therefore
it seems like synchronous writing would be ok. I am looking for
something simple in what seems to be a complex topic. There are
fileinfos, streams, filesteams etc etc.

Does anyone have any advice on which of these objects to start with?
They all seem like overkill for what I want to do.

I want to create/open a file to a specific path like c:\logs\error.log
and write a variable of string class into it. I don't need to read
it.

Thanks,

HH

Nov 18 '05 #2
My Dear friend,

You are having the same problem I had when I switched from VB to VB.NET.
It is not really overkill. It looks complex at first glance, but once you
get used to the new helper classes you will be fine.

What I suggest you do is:

1) Make yourself a small LogWriter Class that implements simple methods like
"WriteToLog", etc.

- OR -

2) Simply write the code to append a line to a certain file:

Dim w As StreamWriter = system.io.File.AppendText("logfile.txt")
w.WriteLine("Your hard drive is dying >:P ")
w.Flush() 'Update underlying file
w.Close()

Good Luck!
"JuneCleaver" <h_************@yahoo.com> wrote in message
news:76*************************@posting.google.co m...
Hello,

I have been digging into writing into a file with the dot net
framework. There is a lot of information on it. I have a web
application and I want to write to a log file when an exception is
encountered. Writing to this file is not mission critical. Therefore
it seems like synchronous writing would be ok. I am looking for
something simple in what seems to be a complex topic. There are
fileinfos, streams, filesteams etc etc.

Does anyone have any advice on which of these objects to start with?
They all seem like overkill for what I want to do.

I want to create/open a file to a specific path like c:\logs\error.log
and write a variable of string class into it. I don't need to read
it.

Thanks,

HH

Nov 18 '05 #3

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

Similar topics

1
by: J-S | last post by:
Hi, I'm a student and new to the .net framework. What is the best way to save configuration properties (not user specific) for a C# application? I read a few messages talking about using...
3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
1
by: JuneCleaver | last post by:
Hello, I have been digging into writing into a file with the dot net framework. There is a lot of information on it. I have a web application and I want to write to a log file when an...
2
by: Kenneth P | last post by:
Hi, I'm developing asp.net (vb) apps in VS.NET 2003, and I'd like to know how you can write style sheet code in a sub in an .aspx page that when it's rendered as html/text/css code in the .aspx...
6
by: JeffDotNet | last post by:
Writing to a registered source in the Application event log I have an asp.net framework 2.0 app that I created on a winxp machine and now I am deploying it to IIS6 on a win server2003 machine. ...
2
by: Thierry Lam | last post by:
I'm using the WMI library for python and I was able to connect to another computer on the network with the following line: c = wmi.WMI(computer="the-network-computer", user="hello",...
1
by: indrajith_varma1 | last post by:
Hi Can we read from an existing excel file, retrieve the values, take the 1st row, append apostophe to all the values in the first row and write back the appended values to the 1st row of the...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have an sql database and I need to do the following, hoping there are some examples I can look at to impliment. 1. Copy an excel file on the server, just using a new name. For example...
16
by: AAaron123 | last post by:
I have a timer. At each tick, say 0.1 second, I write a file. If it takes more than 0.1 second to write the file the app will not work correctly. How can I tell in the tick event if the...
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...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.