PC Review


Reply
Thread Tools Rate Thread

ASP.NET StreamWriter error

 
 
GTi
Guest
Posts: n/a
 
      10th Dec 2005
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 { }
}
}
}

 
Reply With Quote
 
 
 
 
Chris Springer
Guest
Posts: n/a
 
      10th Dec 2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 { }
> }
> }
> }
>



 
Reply With Quote
 
GTi
Guest
Posts: n/a
 
      10th Dec 2005
static void Main(string[] args)
{
LOG.Log("Test of logger");
}

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      10th Dec 2005
GTi <(E-Mail Removed)> 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 - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      10th Dec 2005
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 { }
> }
> }
> }
>
>

 
Reply With Quote
 
GTi
Guest
Posts: n/a
 
      10th Dec 2005
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.

 
Reply With Quote
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      10th Dec 2005

"GTi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
StreamWriter creation error Matt Microsoft Dot NET Framework 1 26th Jul 2008 10:31 AM
difference in Filestream + StreamWriter and just StreamWriter =?Utf-8?B?aXdkdTE1?= Microsoft VB .NET 1 2nd Aug 2006 01:40 PM
ASP.NET C# WriteToFile StreamWriter error: 'StreamWriter' could not be found rex64 Microsoft C# .NET 4 15th Jun 2005 03:46 PM
CDO session and streamwriter error =?Utf-8?B?U2FuZHkgQmVhY2g=?= Microsoft Dot NET Framework 0 29th Sep 2004 11:03 AM
capture using(StreamWriter wr = new StreamWriter()) exceptional kids_pro Microsoft C# .NET 6 3rd Sep 2004 07:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:34 PM.