Search code examples
dockerloggingserilogsinkseq-logging

Serilog Seq Sink with Docker is not capturing events


I am running a web api and console apps on Net Core 3.1 on Windows 10 Professional. I have sinks for console, text file, json file, mssql, and seq. They each log all events, except seq does not log any event.

I installed Docker with the following command:

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

I created the logger with this code:

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();

I see the following in my seq.json file in the D:\Logs\Seq directory:

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

I also see log files written every minute, but none of them capture events from by web api or console apps.

When I go to localhost:8081, I get a "localhost refused to connect." message.

I suspect I have the port numbers wrong, but I don't know. Are they supposed to be different or the same between 1) the docker setup, 2) the seq.json value, 3) the logger creation?


Solution

  • It appears the Seq container in Docker does not play well with my micro SD card D: drive. I simply switched from that to my C: drive and it works fine.