if you wanrt to do logging, look at log4net

On 5 Nov, 06:36, "VIKAS GARG" <[EMAIL PROTECTED]> wrote:
> using System; using System.IO; class Redirect { public static void Main() {
> StreamWriter log_out; try { log_out = new StreamWriter("logfile.txt"); }
> catch (IOException exc) { Console.WriteLine(exc.Message + "Cannot open
> file."); return; } // Direct standard output to the log file.
> Console.SetOut(log_out); Console.WriteLine("This is the start of the log
> file."); for (int i = 0; i < 10; i++) Console.WriteLine(i);
> Console.WriteLine("This is the end of the log file."); log_out.Close(); } }
> In this progg if i do changes as follows why it gives error using System;
> using System.IO; class Redirect { public static void Main() { StreamWriter
> log_out; try { log_out = new StreamWriter("logfile.txt"); } catch
> (IOException exc) { Console.WriteLine(exc.Message + "Cannot open file.");
> return; } // Direct standard output to the log file.
> Console.SetOut(log_out); Console.WriteLine("This is the start of the log
> file."); for (int i = 0; i < 10; i++) Console.WriteLine(i); log_out.Close();
> Console.WriteLine("This is the end of the log file."); } } What if I want to
> take this statement Console.WriteLine("This is the end of the log file.");
> output on console and not in logfile What is the concept beyond this error

Reply via email to