Logging into couchbase using serilog sink in .net core

Hi,
I currently have a .net core 3.1 project and for different database operations using couchbase. and now planning to use couchbase for storing the logs as well.

I have serilog implemented in my code and currently logging into a rolling file. but i want to change this to couchbase instead of a local rolling file.

installed Serilog.Sinks.Couchbase nuget package and used the below code in my program.cs class to connect to couchbase for logging.

 public class Program
    {
        public static IConfiguration Configuration { get; } = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
            .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true)
            .AddEnvironmentVariables()
            .Build();

        public static int Main(string[] args)
        {
           var serversArray = new string {"https://server.com/8091"};
            Log.Logger = new LoggerConfiguration()
               .Enrich.FromLogContext()
               .MinimumLevel.Debug()
               .WriteTo.Couchbase(serversArray, "logBucket", LogLevel.Information)
               .CreateLogger();

            try
            {
                Log.Information("Starting Project");
                CreateHostBuilder(args).Build().Run();
                return 0;
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly");
                return 1;
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                })
                .UseSerilog()
                .UseDefaultServiceProvider((context, options) =>
                {
                    options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
                    options.ValidateOnBuild = true;
                });
    }

But the above code is giving me an exception:

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly ‘Serilog.FullNetFx, Version=1.4.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10’. The system cannot find the file specified.
Source=Serilog.Sinks.Couchbase
StackTrace:
at Serilog.LoggerConfigurationCouchbaseExtensions.Couchbase(LoggerSinkConfiguration loggerConfiguration, String couchbaseUriList, String bucketName, LogEventLevel restrictedToMinimumLevel, Int32 batchPostingLimit, Nullable`1 period, IFormatProvider formatProvider)

Did not find any references on using couchbase for logging using serilog

@abhijith_r

First, let me point out that the package you are using to integrate Serilog isn’t an official extension provided by Couchbase, this is a third-party package of some kind.

As to your issue, this package hasn’t been updated since 2015. It appears to be compatible only with the legacy .NET Framework, not with .NET Core. That is the most likely source of your problem.

That makes sense. thank you @btburnett3