473,586 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(StreamWri ter sw = new StreamWriter("C :\\test.log"))
{
sw.Write(System .DateTime.Now.T oFileTime());
sw.Write("\t");
sw.Write(text);
sw.Write("\n");
}
}
catch { }
}
}
}

Dec 10 '05 #1
6 2487
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.c om> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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(StreamWri ter sw = new StreamWriter("C :\\test.log"))
{
sw.Write(System .DateTime.Now.T oFileTime());
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.c om> 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.co m>
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.T oFileTime());
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(StreamWri ter sw = new StreamWriter("C :\\test.log"))
{
sw.Write(System .DateTime.Now.T oFileTime());
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.c om> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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
2430
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 trying to change a path of an image to an binary string. can someone
4
5566
by: CJ | last post by:
Can one streamwriter object create dynamic files? in nested if statement? example of code
9
4579
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 streamwriter, what you have read into a streamReader? and also can someone explain how they work in simple terms -- The Matrix Insurrection
4
20547
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. using (StreamWriter sw = new StreamWriter (fullAddress , false, Encoding.UTF7)) Error message::::::::::::::::::::::::::::::::::::::::::::::
3
3716
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 streamwriter _fileWriter.Close()
6
10207
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 message: "The process cannot access the file "whatever" because it is being used by another process." I've even tried opening another file using...
2
3356
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 the log file. Now what happens is that if i have the folder in which the stream object creates the log file open in windows explorer, i can see that...
4
8418
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
2951
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 have file access anywhere on the remote server, and therefore I can't figure out how I can create a file. Is it possible to utilize StreamWriter to...
5
3002
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, Write, Read. When I do the second Read, string is null if in the property set, before/after inserting data into cache I write this code: using...
0
7839
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...
0
8200
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
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...
1
7954
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...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
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...
0
3836
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...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.