Closed bobskigit closed 3 years ago
In Startup.cs when you add the structured logger, you can specify the doc store. Pass in the doc store for the logging cluster:
var loggingClusterDocStore = new DocumentStore(...);
loggingClusterDocStore.IgnoreSelfReferencingLoops();
loggingClusterDocStore.Initialize();
// Tell Raven.StructuredLog to use the logging cluster as its doc store.
services.AddLogging(builder => builder.AddRavenStructuredLogger(loggingClusterDocStore));
Doesn't seem to work.
It does not seem to create another RavenDB connection. I am using from your Dependency Injection project for the production cluster?
Any ideas?
What does your code look like?
Startup
services
.AddRavenDbDocStore() // 1. Configures Raven connection using the settings in appsettings.json.
.AddRavenDbAsyncSession();
var loggingClusterDocStore = new DocumentStore(...);
loggingClusterDocStore.IgnoreSelfReferencingLoops();
loggingClusterDocStore.Initialize();
// Tell Raven.StructuredLog to use the logging cluster as its doc store.
services.AddLogging(builder => builder.AddRavenStructuredLogger(loggingClusterDocStore));
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.SetIsOriginAllowed((host) => true)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
services.Configure<APISettings>(
Configuration.GetSection(nameof(APISettings)));
services.AddSingleton<IAPISettings>(sp =>
sp.GetRequiredService<IOptions<APISettings>>().Value);
I see I don't have an overload to .AddRavenStructuredLogger that accepts a different database.
Updating the code now so that you can do this. I'll post here when a new package is available.
OK, I've implemented this and published RavenDB.StructuredLogger v6.0.1. It now has the following overload:
services.AddLogging(builder => builder.AddRavenStructuredLogger(docStore));
Use that overload to send in the docStore used for logging. 👍
Many thanks
Do you have an example where there are two RavenDB clusters, one for logging and one for main production. The logging and production cluster have different URL's and certificates.
Thanks in Advance