Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Writing to a log file
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01405172
Message ID:
01405417
Views:
68
Here's a quick and dirty log routine I use in apps on occasion:
        /// <summary>
        /// Simple Logging method that allows quickly writing a string to a file
        /// </summary>
        /// <param name="output"></param>
        /// <param name="filename"></param>
        public static void LogString(string output, string filename)
        {
            StreamWriter Writer = new StreamWriter(filename, true);
            Writer.WriteLine(DateTime.Now.ToString() + " - " + output);
            Writer.Close();
        }
This version appends to the end of the file.

Note if you do this in ASP.NET you have to give the Web application rights to write in the output path - by default it won't have those rights.

+++ Rick ---
>Hi,
>
>I want to implement a quick-and-dirty error log of my ASP.NET application. Basically I want to find a function similar to VFP StrToFile() so that I can write an error/problem to a text file in a certain folder.
>
>Can someone suggest a class/method for doing that?
>
>Thank you in advance.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform