2

我在 Windows 10 Professional 上的 Net Core 3.1 上运行 Web api 和控制台应用程序。我有控制台、文本文件、json 文件、mssql 和 seq 的接收器。它们每个都记录所有事件,除了 seq 不记录任何事件。

我使用以下命令安装了 Docker:

docker run -d --restart unless-stopped --name seq -e ACCEPT_EULA=Y -v D:\Logs\Seq:/data -p 8081:80 datalust/seq:latest

我使用以下代码创建了记录器:

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Information()
    .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
    .MinimumLevel.Override("System", LogEventLevel.Warning)
    .Enrich.FromLogContext()
    .Enrich.WithMachineName()
    .Enrich.WithEnvironmentUserName()
    .Enrich.WithProcessId()
    .Enrich.WithThreadId()
    .WriteTo.Console()
    .WriteTo.File($@"{Constants.LogsDirectory}log-.txt", LogEventLevel.Information, rollingInterval: RollingInterval.Day)
    .WriteTo.File(new JsonFormatter(), $@"{Constants.LogsDirectory}log-.json", rollingInterval: RollingInterval.Day)
    .WriteTo.MSSqlServer(DatabaseAccess.ConnectionString(context), nameof(ProcessMessageLog), columnOptions: columnOptions)
    .WriteTo.Seq("http://localhost:8081")
    .CreateLogger();

我在 D:\Logs\Seq 目录中的 seq.json 文件中看到以下内容:

  "api": {
    "listenUris": [
       "http://localhost:8081"
    ],

我还看到每分钟写入的日志文件,但它们都没有从 web api 或控制台应用程序捕获事件。

当我去 时localhost:8081,我会收到一条"localhost refused to connect."消息。

我怀疑我的端口号错误,但我不知道。它们在 1) docker 设置、2) seq.json 值、3) 记录器创建之间应该不同还是相同?

4

1 回答 1

1

看来 Docker 中的 Seq 容器不能很好地与我的微型 SD 卡 D: 驱动器配合使用。我只是从那个切换到我的 C: 驱动器,它工作正常。

于 2020-01-28T18:21:43.723 回答