You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.
I am having problems writing documents to Cosmos DB.
I have made two attempts to write to Cosmos - using the appsettings configuration API and using the fluent configuration API.
The sink can connect to the Cosmos DB in question and also create a "Diagnostics" database and a "Logs" collection if those values are not specified. But nothing gets logged to Cosmos DB.
I have downloaded the "ToDo"-sample app from Azure to verify that documents can indeed be written to my Cosmos - and that works. But not the AzureDocumentDB sink.
My fluent configuration is this:
var logger = new LoggerConfiguration()
.WriteTo.ColoredConsole()
.WriteTo.AzureDocumentDB("https://myendpoint.documents.azure.com:443/", "mykey")
.CreateLogger();
logger.Information("Hello friend");
I have updated all dependent nuget packages in the Visual Studio project.
My appsettings configuration is this:
<add key="serilog:using:AzureDocumentDB" value="Serilog.Sinks.AzureDocumentDB" />
<add key="serilog:write-to:AzureDocumentDB.endpointUrl" value="https://myendpoint.documents.azure.com:443/" />
<add key="serilog:write-to:AzureDocumentDB.authorizationKey" value="mykey" />
<!-- Liefspan of log messages in DocumentDB in seconds, leave empty to disable expiration. -->
<add key="serilog:write-to:AzureDocumentDB.timeToLive" value="" />
With C# initialization:
var log = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();
A long shot to the root cause of the issue could be the addition of CORS to Cosmos a couple of months back, but it is just a guess.
I believe test code is hosted in console application and it is terminating before logger gets chance to send log to CosmosDB.
For short lived application or process it is recommended to dispose logger manually to make sure log is transmitted.
I have modified code slightly and can see log in destination store.
using(varlogger=new LoggerConfiguration().WriteTo.ColoredConsole().WriteTo.AzureDocumentDB("https://myendpoint.documents.azure.com:443/","mykey").CreateLogger()){
logger.Information("Lorem ipsum dolor sit amet, consectetur adipiscing elit");}
I am having problems writing documents to Cosmos DB.
I have made two attempts to write to Cosmos - using the appsettings configuration API and using the fluent configuration API.
The sink can connect to the Cosmos DB in question and also create a "Diagnostics" database and a "Logs" collection if those values are not specified. But nothing gets logged to Cosmos DB.
I have downloaded the "ToDo"-sample app from Azure to verify that documents can indeed be written to my Cosmos - and that works. But not the AzureDocumentDB sink.
My fluent configuration is this:
I have updated all dependent nuget packages in the Visual Studio project.
My appsettings configuration is this:
With C# initialization:
A long shot to the root cause of the issue could be the addition of CORS to Cosmos a couple of months back, but it is just a guess.
More details are available on SO at https://stackoverflow.com/questions/55377272/using-xml-configuration-to-log-to-cosmos-db-with-serilog where I originally logged the issue.
The text was updated successfully, but these errors were encountered: