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
    

      

  • 相关阅读:
    Mysql-windows安装
    go-jwt生成token
    github下载慢的问题
    mysql主从复制(二)
    软件下载网站推荐
    Ubuntu14.04 安装ssh
    Ubuntu14.04 更换镜像源
    docker安装记录
    k8s安装记录
    Docker(一):Docker入门教程
  • 原文地址:https://www.cnblogs.com/fudaming/p/15707347.html
Copyright © 2011-2022 走看看