RequestLog plugin in Docker container not working

I use Serilog as logging library and that is working fine also with Docker. It creates all log files as requested. I mount a directory from the host system into my container like so:

docker run -d -p 6083:6083 \
       --name bbopsmanager \
       -v /root/Projects/logs:/logs \
       --hostname bbopsmanager \
       --rm \

Now I try to enable the RequestLogsFeature plugin as follows:

Plugins.Add(new RequestLogsFeature
{
            RequestLogger = new CsvRequestLogger( new FileSystemVirtualFiles(logpath))
});

Logpath is passes from the command line, e.g. in my dockerfile "--logpath", "/logs", \

But nothing happens. Is there any security issues when calling this from docker?? The path is set correctly as is shown in the log output:

2018-11-16 11:18:21.702 +00:00 [DBG] [OperationsManagerServer.AppHost] [ThreadId 1] Registering ServiceStack plugins…
2018-11-16 11:18:21.763 +00:00 [DBG] [OperationsManagerServer.AppHost] [ThreadId 1] Logpath: /logs
2018-11-16 11:18:21.769 +00:00 [DBG] [OperationsManagerServer.AppHost] [ThreadId 1] Registering ServiceStack (Cache) providers…

And what drives me really crazy: If I run it on my Linux Workstation it works and creates a folder requestlogs and there a folder 2018-11 and there I can find a file called 2018-11-16.csv. But as soon as it runs in docker it does nothing but also no error is thrown anywhere.

Does the ServiceStack Virtual File System have a problem with Docker? Or is there any special configuration required??

ServiceStack doesn’t know about or should have to know that it’s running in Docker.

FileSystemVirtualFiles should be configured with the absolute path, if it’s relative to your project you can resolve it with MapProjectPath("~/logs").

It should not be stored in the container, it must be written to the HOST, otherwise the stuff is gone when you remove the container.

To achieve that you have to map a folder of the host into your container. That is done in the docker run command with -v /root/Projects/logs:/logs. So in the container I can cd to /logs and I am effectively on my Docker host.

My project is stored in a folder called app in the container. I tried to enable the plugin with the default constructor (no parameters passed). When running on my Linux box, it creates the sub-folders in the project folder. This does NOT work as soon as it is running in Docker. Looks like FileSystemVirtualFiles is refusing any work when running in Docker!

Is there any way to test FileSystemVirtualFiles by writing a simple hello world file?

Don’t just assume the issue is Docker, the FileSystemVirtualFiles uses .NET File System APIs like everything else, if you’re having issues and the absolute path is valid from within the container check that you have read/write access to it from the .NET Core App (e.g. test reading/writing to it using .NET’s File APIs in Program.cs).

Yeah thats why I am so confused, I configured serilog the same way and it works. I am assuming it is using normal .NET APIs.

Now I added the following lines in apphost.cs just before registering the RequestLog plugin:

Logger.Debug($"Logpath: {logpath}");
var fs = new FileSystemVirtualFiles(logpath);
var testfile = "/testfolder/helloworld.txt";
var filecontent = "Hello World!";
Logger.Debug($"Writing test file '{testfile}' with content '{filecontent}' to '{fs.RootDirectory.RealPath}'");
fs.WriteFile(testfile, filecontent);

Plugins.Add(new RequestLogsFeature
{
     RequestLogger = new CsvRequestLogger(fs)
});

I rebuilt everything and pushed it to my docker registry (quay.io).

Then I pulled that container from another linux box and called my service with /metadata and bingo IT WORKS! The hello world file was created and also the request CSV was created. No idea what is not working in the datacenter. I have to try again. If it is not working there these guys need to check for reasons since they setup fancy firewall rules and SELinux etc…