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

HKLogImport.cs 715 B

2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
123456789101112131415161718192021222324252627
  1. using Serilog;
  2. using System.Diagnostics;
  3. namespace HKLog
  4. {
  5. public class HKLogImport
  6. {
  7. public static void Init(string input)
  8. {
  9. //日志
  10. Log.Logger = new LoggerConfiguration()
  11. .MinimumLevel.Information()
  12. .WriteTo.File($"Logs/{input}.log", rollingInterval: RollingInterval.Day)
  13. .CreateLogger();
  14. }
  15. public static void WriteInfo(string msg)
  16. {
  17. Log.Logger.Information(msg);
  18. Debug.WriteLine(msg);
  19. }
  20. public static void WriteError(Exception ex)
  21. {
  22. Log.Logger.Error(ex, ex.Message);
  23. Debug.WriteLine(ex.ToString());
  24. }
  25. }
  26. }