+1 vote
by (130 points)

Client Project Code

class Program
{
    static async Task Main(string[] args)
    {
        while (true)
        {
            Console.WriteLine($"Hello:{DateTime.Now}");
            await Task.Delay(1000);
        }
    }
}

Console Output
Server Project Code

    class Program
    {
        static void Main(string[] args)
        {
            var server = new SyslogServer(10086);
            server.TcpEnabled = true;

            server.MessageReceived += SyslogMessageReceived;
            server.Start();

            Console.ReadLine();
        }

        private static void SyslogMessageReceived(object sender, SyslogMessageReceivedEventArgs e)
        {
            var content = $"Received:{e.Message.Received} Facility:{e.Message.Facility} Severity:{e.Message.Severity} Text:{e.Message.Text}";
            File.AppendAllText("log.txt", content);
        }
    }

SyslogServer to Open Source Project Rebex.Syslog

Command Line:
docker run --name syslogservice -v usr/netcoreapp3.1:/netcoreapp3.1 -itd mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim dotnet /netcoreapp3.1/Syslog.Sample.dll
docker run -v usr/netcoreapp3.1:/netcoreapp3.1 --log-driver=syslog --log-opt syslog-address=tcp://172.17.0.2:10086 --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}" --log-opt syslog-facility=local6 -itd mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim dotnet /netcoreapp3.1/docker.Sample.dll

console output not write to 'log.txt'

1 Answer

0 votes
by (147k points)
Hello, do you need any feedback from us regarding the code above?
...