.Net app under docker: significant delay in writing logs to the file shared with hosting system

Viewed 68

We have .net app that writes logs with help of Nlog logger to file source, logs are recorded all the time, every second. If you run it on Windows, no dockers, everything works fine: log records appear in the file immediately, but being deployed under our cluster of Linux dockers it takes from several minutes to hours to flash data into the file, which is shared with our host system. I can see data in the database, indicating that app ran successfully, but log file is not changed for a while. Having very little experience with dockers, not sure what it could be caused by, and even where to look at. I found yaml file that looks like this:

mount -v -t cifs //10.153.1.61/apps/configs/stage/testApp/logs /logs/ -o credentials=/smb/smbcredentials;

As it works fine without docker, I believe something is wrong in the way we create images and deploy dockers. Any ideas on where to direct the investigation is very appreciated.

1 Answers

I think your see the slowness because you are trying to write your logs over the CIFS network share, that's a lot of overhead. You should consider using one of the commonly available distributed log handling solutions out there, such as gray log, ELK or Splunk(https://www.splunk.com/)

Looks like NLog has a lot of integrations to choose from. There are very detailed step by step tutorials available that explain the process in fine detail.

Using the centralized log collection not only will speed things up for you, it will let you query / combine logs from multiple containers and build graphs / dashboards giving more insight to you about the current status of your system.

Related