471,310 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 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 2417
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Páll Ólafsson | last post: by
4 posts views Thread by CJ | last post: by
9 posts views Thread by ShadowOfTheBeast | last post: by
7 posts views Thread by =?Utf-8?B?TWlrZQ==?= | last post: by

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.