Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何修复无效URI:asp.net核心问题中无法确定URI的格式_C#_Asp.net Core_Seq Logging - Fatal编程技术网

C# 如何修复无效URI:asp.net核心问题中无法确定URI的格式

C# 如何修复无效URI:asp.net核心问题中无法确定URI的格式,c#,asp.net-core,seq-logging,C#,Asp.net Core,Seq Logging,我在我的Asp.net核心程序中使用serilog和Seq,但我不断得到上述错误。我的Seq服务器正在运行。分别在appsetting.json和startup.cs中找到下面的配置 Appsetting.json StartUp.cs 对于loggingBuilder.AddSeq(“Seq”),您需要传递url而不是Seq // // Summary: // Extends Microsoft.Extensions.Logging.ILoggerFactory with me

我在我的Asp.net核心程序中使用serilog和Seq,但我不断得到上述错误。我的Seq服务器正在运行。分别在
appsetting.json
startup.cs
中找到下面的配置

Appsetting.json

StartUp.cs


对于
loggingBuilder.AddSeq(“Seq”)
,您需要传递url而不是
Seq

    //
// Summary:
//     Extends Microsoft.Extensions.Logging.ILoggerFactory with methods for configuring
//     Seq logging.
public static class SeqLoggerExtensions
{
    //
    // Summary:
    //     Adds a Seq logger configured from the supplied configuration section.
    //
    // Parameters:
    //   loggerFactory:
    //     The logger factory.
    //
    //   configuration:
    //     A configuration section with details of the Seq server connection.
    //
    // Returns:
    //     A logger factory to allow further configuration.
    public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, IConfigurationSection configuration);
    //
    // Summary:
    //     Adds a Seq logger.
    //
    // Parameters:
    //   loggerFactory:
    //     The logger factory.
    //
    //   serverUrl:
    //     The Seq server URL; the default is http://localhost:5341.
    //
    //   apiKey:
    //     A Seq API key to authenticate or tag messages from the logger.
    //
    //   minimumLevel:
    //     The level below which events will be suppressed (the default is Microsoft.Extensions.Logging.LogLevel.Information).
    //
    //   levelOverrides:
    //     A dictionary mapping logger name prefixes to minimum logging levels.
    //
    // Returns:
    //     A logger factory to allow further configuration.
    public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, string serverUrl = "http://localhost:5341", string apiKey = null, LogLevel minimumLevel = LogLevel.Information, IDictionary<string, LogLevel> levelOverrides = null);
    //
    // Summary:
    //     Adds a Seq logger.
    //
    // Parameters:
    //   loggingBuilder:
    //     The logging builder.
    //
    //   serverUrl:
    //     The Seq server URL; the default is http://localhost:5341.
    //
    //   apiKey:
    //     A Seq API key to authenticate or tag messages from the logger.
    //
    // Returns:
    //     A logging builder to allow further configuration.
    public static ILoggingBuilder AddSeq(this ILoggingBuilder loggingBuilder, string serverUrl = "http://localhost:5341", string apiKey = null);
    //
    // Summary:
    //     Adds a Seq logger configured from the supplied configuration section.
    //
    // Parameters:
    //   loggingBuilder:
    //     The logging builder.
    //
    //   configuration:
    //     A configuration section with details of the Seq server connection.
    //
    // Returns:
    //     A logging builder to allow further configuration.
    public static ILoggingBuilder AddSeq(this ILoggingBuilder loggingBuilder, IConfigurationSection configuration);
}
并使用like
loggingBuilder.AddSeq(Configuration.GetSection(“Seq”))

如果需要组合
serilog
Seq
,请参阅


显示您可能应该执行的操作,而不是将
“Seq”
作为参数传递。通过将
Seq
传递到
loggingBuilder.AddSeq(“Seq”)来实现什么
 services.AddLogging(loggingBuilder =>
 {
     loggingBuilder.AddSeq("Seq");
 });
    //
// Summary:
//     Extends Microsoft.Extensions.Logging.ILoggerFactory with methods for configuring
//     Seq logging.
public static class SeqLoggerExtensions
{
    //
    // Summary:
    //     Adds a Seq logger configured from the supplied configuration section.
    //
    // Parameters:
    //   loggerFactory:
    //     The logger factory.
    //
    //   configuration:
    //     A configuration section with details of the Seq server connection.
    //
    // Returns:
    //     A logger factory to allow further configuration.
    public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, IConfigurationSection configuration);
    //
    // Summary:
    //     Adds a Seq logger.
    //
    // Parameters:
    //   loggerFactory:
    //     The logger factory.
    //
    //   serverUrl:
    //     The Seq server URL; the default is http://localhost:5341.
    //
    //   apiKey:
    //     A Seq API key to authenticate or tag messages from the logger.
    //
    //   minimumLevel:
    //     The level below which events will be suppressed (the default is Microsoft.Extensions.Logging.LogLevel.Information).
    //
    //   levelOverrides:
    //     A dictionary mapping logger name prefixes to minimum logging levels.
    //
    // Returns:
    //     A logger factory to allow further configuration.
    public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, string serverUrl = "http://localhost:5341", string apiKey = null, LogLevel minimumLevel = LogLevel.Information, IDictionary<string, LogLevel> levelOverrides = null);
    //
    // Summary:
    //     Adds a Seq logger.
    //
    // Parameters:
    //   loggingBuilder:
    //     The logging builder.
    //
    //   serverUrl:
    //     The Seq server URL; the default is http://localhost:5341.
    //
    //   apiKey:
    //     A Seq API key to authenticate or tag messages from the logger.
    //
    // Returns:
    //     A logging builder to allow further configuration.
    public static ILoggingBuilder AddSeq(this ILoggingBuilder loggingBuilder, string serverUrl = "http://localhost:5341", string apiKey = null);
    //
    // Summary:
    //     Adds a Seq logger configured from the supplied configuration section.
    //
    // Parameters:
    //   loggingBuilder:
    //     The logging builder.
    //
    //   configuration:
    //     A configuration section with details of the Seq server connection.
    //
    // Returns:
    //     A logging builder to allow further configuration.
    public static ILoggingBuilder AddSeq(this ILoggingBuilder loggingBuilder, IConfigurationSection configuration);
}
    "Seq": {
  "ServerUrl": "http://localhost:5341",
  "ApiKey": "1234567890",
  "MinimumLevel": "Trace",
  "LevelOverride": {
    "Microsoft": "Warning"
  }
}
Log.Logger = new LoggerConfiguration()
        .WriteTo.Console()
        .WriteTo.Seq("http://localhost:5341")
        .CreateLogger();