.Net – Pushing logs from web application to Docker container running Fluentd

I want to push .net web application logs to the fluentd image running on Docker container. For this task I installed Docker Toolbox and I ran fluentd image on Docker.

Firstly I tried sending text to the container via telnet and container received those messages and printed on command line.

  • Two docker nodes running .NET Services, talking to each other
  • Microsoft Compiler in Docker
  • Starting a barebones MVC C# ASP.NET project in Docker gives “Compilation Error”
  • How to run .NET unit tests in a docker container
  • Docker: Share the same .so library different containers without compiling into each
  • Can't connect to Mongo DB in .Net Core api
  • For sending logs from web application, I tried the method described here (using Nlog.Targets.Fluentd package) https://groups.google.com/d/msg/fluentd/bjf6V0E8oAQ/cTBlxXMbzkAJ .
    Connection details like host, port, tag is same as the ones I used in telnet, however I couldn’t send logs to the container.

    Docker image repository name is “fluent” and tag name is “latest”. This is how I run fluentd image on docker:

    docker run -it ip 47001:24224 fluent:latest
    

    And this is how I use Nlog.Targets.Fluentd methods:

    using (var fluentdTarget = new NLog.Targets.Fluentd())
    {
        fluentdTarget.Layout = new NLog.Layouts.SimpleLayout("${longdate}|${level}|${callsite}|${logger}|${message}");
        fluentdTarget.Host = "192.168.99.100"; // IP of the docker
        fluentdTarget.Port = 47001; // mapped port number on host
        fluentdTarget.Tag = "fluent:latest"; 
        config.AddTarget("fluentd", fluentdTarget);
        config.LoggingRules.Add(new NLog.Config.LoggingRule("demo", LogLevel.Debug, fluentdTarget));
        var loggerFactory = new LogFactory(config);
        var logger = loggerFactory.GetLogger("demo");
        logger.Info("Hello World!");
    }
    

    How can I solve this issue? Is there any other way to send logs to the container from web application?

  • Restrict ssh user to their respective docker container
  • Fig up: Cannot find module - docker run works
  • How to create new databases and collections when using MongoDB with Docker?
  • Connect to Docker MySQL container from localhost?
  • Docker : publish port automatically with exact port number match
  • Building docker images from a source directory using different dockerfiles
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.