473,372 Members | 912 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,372 software developers and data experts.

ASP.NET StreamWriter error

GTi
I have created a simple logger for my ASP.NET 2.0 application.
I have this static function.
My problem is that no data is created in the test.log file.
I have added ASPNET user account administrator rights.
What am I missing here?

namespace MyNameSpace
{
public class LOG
{
public LOG()
{
}
public static void Log(string text)
{
try
{
using(StreamWriter sw = new StreamWriter("C:\\test.log"))
{
sw.Write(System.DateTime.Now.ToFileTime());
sw.Write("\t");
sw.Write(text);
sw.Write("\n");
}
}
catch { }
}
}
}

Dec 10 '05 #1
6 2475
Post your usage of this class in your program.

Chris

--
Securing your systems is much like fighting off disease -- as long as you
maintain basic hygiene, you're likely to be okay, but you'll never be
invulnerable.

Steve Shah - Unix Systems Network Administrator
"GTi" <tu****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have created a simple logger for my ASP.NET 2.0 application.
I have this static function.
My problem is that no data is created in the test.log file.
I have added ASPNET user account administrator rights.
What am I missing here?

namespace MyNameSpace
{
public class LOG
{
public LOG()
{
}
public static void Log(string text)
{
try
{
using(StreamWriter sw = new StreamWriter("C:\\test.log"))
{
sw.Write(System.DateTime.Now.ToFileTime());
sw.Write("\t");
sw.Write(text);
sw.Write("\n");
}
}
catch { }
}
}
}

Dec 10 '05 #2
GTi
static void Main(string[] args)
{
LOG.Log("Test of logger");
}

Dec 10 '05 #3
GTi <tu****@gmail.com> wrote:
I have created a simple logger for my ASP.NET 2.0 application.
I have this static function.
My problem is that no data is created in the test.log file.
I have added ASPNET user account administrator rights.
What am I missing here?


Well, I suggest you use ASP.NET's normal logging features to log any
exceptions, instead of catching and then ignoring them. Going through
it with a debugger would help you, too.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 10 '05 #4
public static void Log(string text)
{
try
{
using (StreamWriter sw = new StreamWriter("C:\\test.log"))
{
sw.Write(System.DateTime.Now.ToFileTime());
sw.Write("\t");
sw.Write(text);
sw.Write("\n");
sw.Flush();
sw.Close();
}
}
catch
{
// don't swallow exceptions!
}
}

--Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"GTi" wrote:
I have created a simple logger for my ASP.NET 2.0 application.
I have this static function.
My problem is that no data is created in the test.log file.
I have added ASPNET user account administrator rights.
What am I missing here?

namespace MyNameSpace
{
public class LOG
{
public LOG()
{
}
public static void Log(string text)
{
try
{
using(StreamWriter sw = new StreamWriter("C:\\test.log"))
{
sw.Write(System.DateTime.Now.ToFileTime());
sw.Write("\t");
sw.Write(text);
sw.Write("\n");
}
}
catch { }
}
}
}

Dec 10 '05 #5
GTi
I'm building a library to use on ASP.NET, windows forms and windows NT
services.
So I need to build generic functions.
And I solved my problem. I needed to reboot the computer before it
worked.
I did't see any processes from user ASPNET active so I don't know why I
must reboot the computer.

Dec 10 '05 #6

"GTi" <tu****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I'm building a library to use on ASP.NET, windows forms and windows NT
services.
So I need to build generic functions.
And I solved my problem. I needed to reboot the computer before it
worked.
I did't see any processes from user ASPNET active so I don't know why I
must reboot the computer.


As you did change the ASPNET user rights, you should have restarted IIS for
the worker process to pick up the new access token.

Willy.


Dec 10 '05 #7

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

Similar topics

1
by: Páll Ólafsson | last post by:
Hi I keep getting this error if Im using UTF7? An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Conversion buffer overflow. Only...
4
by: CJ | last post by:
Can one streamwriter object create dynamic files? in nested if statement? example of code
9
by: ShadowOfTheBeast | last post by:
Hi, I have got a major headache understanding streamReader and streamWriter relationship. I know how to use the streamreader and streamwriter independently. but how do you write out using the...
4
by: rex64 | last post by:
I am getting an error message and I have not been able to figure hot how to fix it. I have done some research with no answers yet. I found this code that may help? Not sure what to do with it....
3
by: Don | last post by:
I have a strange bug popping up every once in a while. I've got a section of code that executes these statements when working with a streamwriter: --- Start --- .... ' Close the...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
2
by: sameer | last post by:
Hi, My very simple application VB.NET Visual Studio 2003 console application uses a log file to write some text to it. I am using StreamWriter object to create and open and then append text to...
4
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
7
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I'm building an ASP.NET site which is hosted on a remote server. When I try to create a new file using StreamWriter I must specify the drive location where the file will be saved. I don't...
5
by: BLUE | last post by:
I insert a string in cache in a property set and I retrieve that string in the get. I retrieve my string with Read web method and I insert it with Write web method: to try cache I do Read,...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.