You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Logging.cs 937 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. namespace Shadowsocks.Controller
  6. {
  7. public class Logging
  8. {
  9. public static string LogFile;
  10. public static bool OpenLogFile()
  11. {
  12. try
  13. {
  14. string temppath = Path.GetTempPath();
  15. LogFile = Path.Combine(temppath, "shadowsocks.log");
  16. FileStream fs = new FileStream(LogFile, FileMode.Append);
  17. TextWriter tmp = Console.Out;
  18. StreamWriter sw = new StreamWriter(fs);
  19. sw.AutoFlush = true;
  20. Console.SetOut(sw);
  21. Console.SetError(sw);
  22. return true;
  23. }
  24. catch (IOException e)
  25. {
  26. Console.WriteLine(e.ToString());
  27. return false;
  28. }
  29. }
  30. }
  31. }