zoukankan      html  css  js  c++  java
  • Serilog

    {
      "Serilog": {
        "MinimumLevel": {
          "Default": "Information",
          "Override": {
            "Microsoft": "Information",
            "System": "Warning",
            "Microsoft.AspNetCore": "Warning",
            "Microsoft.EntityFrameworkCore": "Error",
            "Orleans.Runtime.SiloLogStatistics": "Warning",
            "Orleans.Runtime.GrainDirectory.LocalGrainDirectory": "Warning",
            "Orleans.Runtime.Management.ManagementGrain": "Warning",
            "Orleans.Runtime.ReminderService.LocalReminderService": "Warning",
            "Orleans.Runtime.DeploymentLoadPublisher": "Warning",
            "Orleans.Runtime.SiloControl": "Warning",
            "Orleans.Runtime.CounterStatistic": "Warning",
            "Orleans.Runtime.MembershipService.MembershipTableManager": "Warning" 
          }
        },
        "WriteTo": [
          {
            "Name": "Console",
            "Args": {
              "theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
              "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3} {Message} <{SourceContext}> {NewLine}{Exception}]"
              //"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
            }
          }
          //{
          //  "Name": "File",
          //  "Args": {
          //    "path": "logs/log.txt",
          //    "rollingInterval": "Day",
          //    "retainedFileCountLimit": 60,
          //    "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3} {Message} <{SourceContext}> {NewLine}{Exception}]",
          //    "fileSizeLimitBytes": 3145728 //3M default 1G
          //    "rollOnFileSizeLimit": true
          //  }
          //},
          //{
          //  "Name": "EventCollector",
          //  "Args": {
          //    "splunkCollectorBatchIntervalInSeconds": "100",
          //    "splunkCollectorBatchSizeLimit": "2",
          //    "auditLoggingSourceType": "DistributedCluster",
          //    "splunkHost": "http://localhost",
          //    "eventCollectorToken": "some-GUID-here"
          //  }
          //}
        ],
        "Properties": {
          "Application":  "DstributedService"
        }
      }
    }
    

      

            private static readonly string Env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
    

      

                #region Serilog
                var loggingConfig = new LoggerConfiguration()
                    .Enrich.FromLogContext()
                    .Enrich.WithMachineName()
                    .Enrich.WithThreadId()
                    .Enrich.WithProperty("Environment", Env)
                    .ReadFrom.Configuration(new ConfigurationBuilder()
                        .AddJsonFile("Serilog.json")
                        .Build());
    
                if (Env == "Development")
                {
                    var levelSwitch = new LoggingLevelSwitch();
                    levelSwitch.MinimumLevel = LogEventLevel.Debug;
                    loggingConfig.MinimumLevel.ControlledBy(levelSwitch);
                }
    
                Log.Logger = loggingConfig.CreateLogger();
                #endregion
    

      

  • 相关阅读:
    Macbook上如何把中文文本转成UTF-8
    防火墙学习笔记
    百万长连接并发的限制因素
    meminfo中的字段都是什么意思?
    维护TCP长连接时系统配置的参数net.ipv4.tcp_keepalive_time不生效
    小程序如何利用CSS画出箭头
    cephfs配额问题
    ceph机房断电之后重启遇到问题“Transaction order is cyclic. See system logs for details.”
    valgrind的使用方法
    程序员的创业经历
  • 原文地址:https://www.cnblogs.com/fudaming/p/15707347.html
Copyright © 2011-2022 走看看