Logging to couchbase from ASP Net Core 3.1 or 5.0

How to save logs to Couchbase from ASP Net Core 3.1 or 5.0? Any logging framework like Serilog or NLog.

Hi @prem111 ,

Have you check out the documentation on this: Collecting Information and Logging in the .NET SDK with Couchbase Server | Couchbase Docs

Thanks for the reply.
As per this link, Serilog logs to a file (txt). But my requirement is to save the errors and warnings to Couchbase.

How do I do that?

Oh, sorry, I didn’t read carefully enough :slight_smile:

I believe there are some libraries out there that support Serilog and NLog using Couchbase as a sink. It doesn’t look like they’ve been updated recently, and they are community projects (not officially supported by Couchbase Inc).

I’ll also tag @jmorris and @Richard_Ponton who might have some more insight.

@jmorris , @Richard_Ponton
Any updates on this?

@prem111 -

As @matthew.groves mentioned there are libraries using Couchbase as a sink, however, they have not been updated recently. These are 3rd party solutions.

If you wanted to simply have your logging provider write to Couchbase, then it wouldn’t be too difficult to roll your own ILoggerFactory/ILoggerProvider and ILogger using Couchbase as the back end store.


Note that I have an example (in addition to the docs) of plugging in a different logger recently:

As an aside, I’d be very careful writing a logger that sends logs from ILoggerFactory to Couchbase. The Couchbase SDK also generates logs into the ILoggerFactory. If you aren’t careful to filter out those logs, you could easily create an infinite loop where SDK errors generate logs that generate more SDK errors, and on, and on, and on.