Using Xml-configuration to log to Cosmos DB with serilogUsing Serilog from within WCFSerilog - Logging in multiple languagesSerilog stops logging eventsAzure Function with Cosmos MongoDB integration not savingCreating method to return Serilog LoggerConfiguration (Asp.Net Core 2.0)Serilog not creating log file when running on LinuxSerilog Net Core Additional Columns IssueWhy won't Serilog log to table using WriteTo.MSSqlServer sink?Problems with serilog.settings.appsettings and file rollover intervalPersisting EventType with Serilog

What should we do with manuals from the 80s?

What is the purpose/function of this power inductor in parallel?

global variant of csname…endcsname

Does writing regular diary entries count as writing practice?

Would molten tin solidify and coat an organic horn?

Is Fourier series a sampled version of Fourier transform?

What is the question mark?

Are there any rules on how characters go from 0th to 1st level in a class?

Physical Interpretation of an Overdamped Pendulum

What would cause a nuclear power plant to break down after 2000 years, but not sooner?

Why does the USA have 'First Lady' as a position of power?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

Upside down reversion for a Greek letter

Why is the battery jumpered to a resistor in this schematic?

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

Short comic about alien explorers visiting an abandoned world with giant statues that turn out to be alive but move very slowly

How do I answer an interview question about how to handle a hard deadline I won't be able to meet?

6502: is BCD *fundamentally* the same performance as non-BCD?

Is a USB 3.0 device possible with a four contact USB 2.0 connector?

Does Medium Armor's Max dex also put a cap on the negative side?

What's a good pattern to calculate a variable only when it is used the first time?

Do I need to start off my book by describing the character's "normal world"?

Why does "auf der Strecke bleiben" mean "to fall by the wayside"?

How do I pass a "list of lists" as the argument to a function of the form F[x,y]?



Using Xml-configuration to log to Cosmos DB with serilog


Using Serilog from within WCFSerilog - Logging in multiple languagesSerilog stops logging eventsAzure Function with Cosmos MongoDB integration not savingCreating method to return Serilog LoggerConfiguration (Asp.Net Core 2.0)Serilog not creating log file when running on LinuxSerilog Net Core Additional Columns IssueWhy won't Serilog log to table using WriteTo.MSSqlServer sink?Problems with serilog.settings.appsettings and file rollover intervalPersisting EventType with Serilog






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to go away from statically linking my code to specific serilog sinks and use xml-configuration in appsettings instead.



I used to have code like this:



serilogConfig = serilogConfig.WriteTo.AzureDocumentDB(
new Uri(logConfig.AzureDocumentDBConfig.Endpoint),
logConfig.AzureDocumentDBConfig.AuthKey,
logConfig.AzureDocumentDBConfig.Database,
logConfig.AzureDocumentDBConfig.Collection);


The C#-code to load from appsettings is this:



var log = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();


I am trying to change this to e.g. this configuration data



<add key="serilog:using:AzureDocumentDB" value="Serilog.Sinks.AzureDocumentDB" />
<add key="serilog:write-to:AzureDocumentDB.endpointUrl" value="https://my_prefix.documents.azure.com:443/" />
<add key="serilog:write-to:AzureDocumentDB.authorizationKey" value="mykey" />
<add key="serilog:write-to:AzureDocumentDB.databaseName" value="mydatabasename" />
<add key="serilog:write-to:AzureDocumentDB.collectionName" value="mycollectionname" />
<add key="serilog:write-to:AzureDocumentDB.timeToLive" value="3600" />


My problem: nothing is written to Cosmos.



Am I missing something obvious here? I have checked the config values a million times - and they are correct. I have also tried to use non-existing values for "databaseName" and "collectionName", and serilog creates these artifacts just fine in DocumentDB - to it is able to connect to Cosmos.



And finally - this is the entire code in my test console app:



var log = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();

log.Information("Test");
log.Error(new ApplicationException("some error"), "stuff failed");
log.Warning("Test2");

Console.WriteLine("Press Enter to exit...");


Logging level in app config is this:



<add key="serilog:minimum-level" value="Verbose" />


Thanks :-)



UPDATE:



I have created a completely new Visual Studio project where I am using the fluent configuration API. My code is this:



var logger = new LoggerConfiguration()
.WriteTo.ColoredConsole()
.WriteTo.AzureDocumentDB("https://myendpoint.documents.azure.com:443/", "mykey")
.CreateLogger();


The behavior is exactly the same. Nothing is written to Cosmos. If I do not specify collection name and database name, a "Logs" collection and a "Diagnostics" database is created in Cosmos - but nothing is written.



I am beginning to question life itself and the meaning with it ... what am I missing here?



For testing purposes I have created a new Cosmos instance and downloaded the "ToDo"-app that writes to the database. This one works, and if I change the pointers to my original Cosmos DB, it can write to this as well. My own code cannot write to the new DB created for test.










share|improve this question
































    0















    I am trying to go away from statically linking my code to specific serilog sinks and use xml-configuration in appsettings instead.



    I used to have code like this:



    serilogConfig = serilogConfig.WriteTo.AzureDocumentDB(
    new Uri(logConfig.AzureDocumentDBConfig.Endpoint),
    logConfig.AzureDocumentDBConfig.AuthKey,
    logConfig.AzureDocumentDBConfig.Database,
    logConfig.AzureDocumentDBConfig.Collection);


    The C#-code to load from appsettings is this:



    var log = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();


    I am trying to change this to e.g. this configuration data



    <add key="serilog:using:AzureDocumentDB" value="Serilog.Sinks.AzureDocumentDB" />
    <add key="serilog:write-to:AzureDocumentDB.endpointUrl" value="https://my_prefix.documents.azure.com:443/" />
    <add key="serilog:write-to:AzureDocumentDB.authorizationKey" value="mykey" />
    <add key="serilog:write-to:AzureDocumentDB.databaseName" value="mydatabasename" />
    <add key="serilog:write-to:AzureDocumentDB.collectionName" value="mycollectionname" />
    <add key="serilog:write-to:AzureDocumentDB.timeToLive" value="3600" />


    My problem: nothing is written to Cosmos.



    Am I missing something obvious here? I have checked the config values a million times - and they are correct. I have also tried to use non-existing values for "databaseName" and "collectionName", and serilog creates these artifacts just fine in DocumentDB - to it is able to connect to Cosmos.



    And finally - this is the entire code in my test console app:



    var log = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

    log.Information("Test");
    log.Error(new ApplicationException("some error"), "stuff failed");
    log.Warning("Test2");

    Console.WriteLine("Press Enter to exit...");


    Logging level in app config is this:



    <add key="serilog:minimum-level" value="Verbose" />


    Thanks :-)



    UPDATE:



    I have created a completely new Visual Studio project where I am using the fluent configuration API. My code is this:



    var logger = new LoggerConfiguration()
    .WriteTo.ColoredConsole()
    .WriteTo.AzureDocumentDB("https://myendpoint.documents.azure.com:443/", "mykey")
    .CreateLogger();


    The behavior is exactly the same. Nothing is written to Cosmos. If I do not specify collection name and database name, a "Logs" collection and a "Diagnostics" database is created in Cosmos - but nothing is written.



    I am beginning to question life itself and the meaning with it ... what am I missing here?



    For testing purposes I have created a new Cosmos instance and downloaded the "ToDo"-app that writes to the database. This one works, and if I change the pointers to my original Cosmos DB, it can write to this as well. My own code cannot write to the new DB created for test.










    share|improve this question




























      0












      0








      0








      I am trying to go away from statically linking my code to specific serilog sinks and use xml-configuration in appsettings instead.



      I used to have code like this:



      serilogConfig = serilogConfig.WriteTo.AzureDocumentDB(
      new Uri(logConfig.AzureDocumentDBConfig.Endpoint),
      logConfig.AzureDocumentDBConfig.AuthKey,
      logConfig.AzureDocumentDBConfig.Database,
      logConfig.AzureDocumentDBConfig.Collection);


      The C#-code to load from appsettings is this:



      var log = new LoggerConfiguration()
      .ReadFrom.AppSettings()
      .CreateLogger();


      I am trying to change this to e.g. this configuration data



      <add key="serilog:using:AzureDocumentDB" value="Serilog.Sinks.AzureDocumentDB" />
      <add key="serilog:write-to:AzureDocumentDB.endpointUrl" value="https://my_prefix.documents.azure.com:443/" />
      <add key="serilog:write-to:AzureDocumentDB.authorizationKey" value="mykey" />
      <add key="serilog:write-to:AzureDocumentDB.databaseName" value="mydatabasename" />
      <add key="serilog:write-to:AzureDocumentDB.collectionName" value="mycollectionname" />
      <add key="serilog:write-to:AzureDocumentDB.timeToLive" value="3600" />


      My problem: nothing is written to Cosmos.



      Am I missing something obvious here? I have checked the config values a million times - and they are correct. I have also tried to use non-existing values for "databaseName" and "collectionName", and serilog creates these artifacts just fine in DocumentDB - to it is able to connect to Cosmos.



      And finally - this is the entire code in my test console app:



      var log = new LoggerConfiguration()
      .ReadFrom.AppSettings()
      .CreateLogger();

      log.Information("Test");
      log.Error(new ApplicationException("some error"), "stuff failed");
      log.Warning("Test2");

      Console.WriteLine("Press Enter to exit...");


      Logging level in app config is this:



      <add key="serilog:minimum-level" value="Verbose" />


      Thanks :-)



      UPDATE:



      I have created a completely new Visual Studio project where I am using the fluent configuration API. My code is this:



      var logger = new LoggerConfiguration()
      .WriteTo.ColoredConsole()
      .WriteTo.AzureDocumentDB("https://myendpoint.documents.azure.com:443/", "mykey")
      .CreateLogger();


      The behavior is exactly the same. Nothing is written to Cosmos. If I do not specify collection name and database name, a "Logs" collection and a "Diagnostics" database is created in Cosmos - but nothing is written.



      I am beginning to question life itself and the meaning with it ... what am I missing here?



      For testing purposes I have created a new Cosmos instance and downloaded the "ToDo"-app that writes to the database. This one works, and if I change the pointers to my original Cosmos DB, it can write to this as well. My own code cannot write to the new DB created for test.










      share|improve this question
















      I am trying to go away from statically linking my code to specific serilog sinks and use xml-configuration in appsettings instead.



      I used to have code like this:



      serilogConfig = serilogConfig.WriteTo.AzureDocumentDB(
      new Uri(logConfig.AzureDocumentDBConfig.Endpoint),
      logConfig.AzureDocumentDBConfig.AuthKey,
      logConfig.AzureDocumentDBConfig.Database,
      logConfig.AzureDocumentDBConfig.Collection);


      The C#-code to load from appsettings is this:



      var log = new LoggerConfiguration()
      .ReadFrom.AppSettings()
      .CreateLogger();


      I am trying to change this to e.g. this configuration data



      <add key="serilog:using:AzureDocumentDB" value="Serilog.Sinks.AzureDocumentDB" />
      <add key="serilog:write-to:AzureDocumentDB.endpointUrl" value="https://my_prefix.documents.azure.com:443/" />
      <add key="serilog:write-to:AzureDocumentDB.authorizationKey" value="mykey" />
      <add key="serilog:write-to:AzureDocumentDB.databaseName" value="mydatabasename" />
      <add key="serilog:write-to:AzureDocumentDB.collectionName" value="mycollectionname" />
      <add key="serilog:write-to:AzureDocumentDB.timeToLive" value="3600" />


      My problem: nothing is written to Cosmos.



      Am I missing something obvious here? I have checked the config values a million times - and they are correct. I have also tried to use non-existing values for "databaseName" and "collectionName", and serilog creates these artifacts just fine in DocumentDB - to it is able to connect to Cosmos.



      And finally - this is the entire code in my test console app:



      var log = new LoggerConfiguration()
      .ReadFrom.AppSettings()
      .CreateLogger();

      log.Information("Test");
      log.Error(new ApplicationException("some error"), "stuff failed");
      log.Warning("Test2");

      Console.WriteLine("Press Enter to exit...");


      Logging level in app config is this:



      <add key="serilog:minimum-level" value="Verbose" />


      Thanks :-)



      UPDATE:



      I have created a completely new Visual Studio project where I am using the fluent configuration API. My code is this:



      var logger = new LoggerConfiguration()
      .WriteTo.ColoredConsole()
      .WriteTo.AzureDocumentDB("https://myendpoint.documents.azure.com:443/", "mykey")
      .CreateLogger();


      The behavior is exactly the same. Nothing is written to Cosmos. If I do not specify collection name and database name, a "Logs" collection and a "Diagnostics" database is created in Cosmos - but nothing is written.



      I am beginning to question life itself and the meaning with it ... what am I missing here?



      For testing purposes I have created a new Cosmos instance and downloaded the "ToDo"-app that writes to the database. This one works, and if I change the pointers to my original Cosmos DB, it can write to this as well. My own code cannot write to the new DB created for test.







      azure-cosmosdb serilog azure-cosmosdb-sqlapi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 12:45







      Jesper Lund Stocholm

















      asked Mar 27 at 12:31









      Jesper Lund StocholmJesper Lund Stocholm

      9862 gold badges13 silver badges34 bronze badges




      9862 gold badges13 silver badges34 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0














          Well, it turns out that I was indeed missing something obvious. The application thread ended before data could be pushed/flushed to Cosmos.



          https://github.com/serilog/serilog-sinks-azuredocumentdb/issues/82






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377272%2fusing-xml-configuration-to-log-to-cosmos-db-with-serilog%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Well, it turns out that I was indeed missing something obvious. The application thread ended before data could be pushed/flushed to Cosmos.



            https://github.com/serilog/serilog-sinks-azuredocumentdb/issues/82






            share|improve this answer





























              0














              Well, it turns out that I was indeed missing something obvious. The application thread ended before data could be pushed/flushed to Cosmos.



              https://github.com/serilog/serilog-sinks-azuredocumentdb/issues/82






              share|improve this answer



























                0












                0








                0







                Well, it turns out that I was indeed missing something obvious. The application thread ended before data could be pushed/flushed to Cosmos.



                https://github.com/serilog/serilog-sinks-azuredocumentdb/issues/82






                share|improve this answer













                Well, it turns out that I was indeed missing something obvious. The application thread ended before data could be pushed/flushed to Cosmos.



                https://github.com/serilog/serilog-sinks-azuredocumentdb/issues/82







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 13:55









                Jesper Lund StocholmJesper Lund Stocholm

                9862 gold badges13 silver badges34 bronze badges




                9862 gold badges13 silver badges34 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377272%2fusing-xml-configuration-to-log-to-cosmos-db-with-serilog%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현