serilog-archive / serilog-sinks-azuredocumentdb

A Serilog sink that writes to Azure DocumentDB
Apache License 2.0
17 stars 15 forks source link

Nothing logged written to database #83

Closed MPapst closed 5 years ago

MPapst commented 5 years ago

Hi,

I tried a minimal sample with a cosmosdb, but unfortunately I do not see any documents dropped into the database.

Sample:

class Program
    {
        static void Main()
        {
            using (var logger = new LoggerConfiguration()
                .Enrich.FromLogContext()
                .Enrich.WithProperty("Application", "Test-Console")
                .WriteTo.AzureDocumentDB(
                    "https://mpa-logtest-core.documents.azure.com:443/", 
                    "****",
                    restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose,
                    storeTimestampInUtc: true,
                    timeToLive: 60*60*24*14,
                    logBufferSize: 1000,
                    batchSize: 10)
                .WriteTo.Console()
                .CreateLogger())
            {

                Log.Logger = logger;

                logger.Information("Test");
                logger.Error(new Exception("Test"), "Exception");

                Enumerable.Range(1, 10000).ToList().ForEach(x => logger.Fatal("Hallo {x}", x));

                Console.WriteLine("Hello World!");

            }

            //Thread.Sleep(600 * 1000);

            Log.CloseAndFlush();
        }
    }

Even with the Wait time, nothing happens in the database. I see a lot of traffice between my PC and the database endpoint, which is actually TLS encrypted, but it is there.

Anything I am doing wrong?

Edit: code sample changed to Cosmos DB from Mongo DB (supplied the wrong test)

MPapst commented 5 years ago

... sometimes it "just works" if you try it once more :)