Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Writing to a log file
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01405172
Message ID:
01405417
Vues:
67
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?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform