Created
December 15, 2018 14:37
-
-
Save antoantonyk/4ea9c654ac4b0f653ee156eb192efa56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string logFile = "log-" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; | |
string filePath = WebConfigurationManager.AppSettings["LogPath"].ToString(); | |
//example --- c:/website/Logs/ | |
if (!string.IsNullOrEmpty(filePath)) | |
{ | |
FileInfo fileInfo = new FileInfo(filePath); | |
if (!fileInfo.Exists) | |
Directory.CreateDirectory(filePath); | |
using (StreamWriter writer = new StreamWriter(filePath + logFile, true)) | |
{ | |
writer.WriteLine("IpAddress :" + ipAddress + "<br/>" + Environment.NewLine + | |
"" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); | |
writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment