Monday, September 15, 2014

Writing the log file from asp.net

Step1:- Copy these two methods into code file and access the those methods in your project where you want


public void ExceptionHandler(string ExceptionMessage)
        {
            try
            {
                // string root = Directory.GetCurrentDirectory() + "\\Log";
                // if (!Directory.Exists(root))
                // {
                // Directory.CreateDirectory(root);
                // }

                string root = "C:\\Log\\";
                string path = root + "SampleLog" + System.DateTime.Now.ToString("ddMMyyy") + ".txt";

                CallExceptionHandler(path, ExceptionMessage);

            }
            catch (Exception)
            { }
        }
Read More »