No complicatedAlgorithmAnd there is no intention to use something like log4net. You can view the log information in the directory file.
One sentence: simple and practical.
Public static void log (string message)
{
If (message! = "")
{
Random randobj = new random (datetime. Now. millisecond );
Int file = randobj. Next () + 1;
String filename = datetime. Now. tostring ("yyyymmdd") + ". txt ";
Try
{
Fileinfo Fi = new fileinfo (httpcontext. Current. server. mappath ("~ // Log // "+ filename ));
If (! Fi. exists)
{
Using (streamwriter Sw = Fi. createtext ())
{
Sw. writeline (datetime. Now + "\ n" + message + system. environment. newline );
Sw. Close ();
}
}
Else
{
Using (streamwriter Sw = Fi. appendtext ())
{
Sw. writeline (datetime. Now + "\ n" + message + system. environment. newline );
Sw. Close ();
}
}
}
Catch
{
}
}
}
Using httpcontext. Current. Server with system. appdomain. current can be used in CS applicationsProgram.