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

  • Debug on Docker throws an error
  • Connect to SQL Server database from a docker container
  • X509CertificateValidationMode not working in Linux?
  • Two docker nodes running .NET Services, talking to each other
  • Could not run asp.net mvc 6 on Docker
  • Build docker in ASP.NET Core: “no such file or directory” error
  • 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?

  • Confluence Error 500 while setup
  • Error: failed to checkpoint one or more containers
  • Docker: Add a restart policy to a container that was already created
  • How insert an existing EC2 instance as container host in docker-machine?
  • output file after docker image is created through Dockerfile
  • CoreOS member node will not start when using “etcdctl member add”
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.