.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.

  • curl_slist_free_all() causes segfault on GKE w/ Debian 8.7
  • As a asp.net MVC dev, Why and when to use a docker?
  • Control lifetime of .NET Core console application hosted in docker
  • Run VSCode in Dotnet docker container
  • Docker cross compile for ARM without hard-float
  • Cannot run asp.net 5 from docker
  • 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?

  • automated docker hub builds won't trigger
  • Docker container fails to connect to second container when running under Compose
  • Configuring Hipache with etcd
  • Docker Machine vs Docker run
  • Not able to read the image LABEL key and values of particular image using AWS java APIs
  • from an ec2 instance spin up another ec2 instance and push a csv file on it
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.