OracleBackgroundSink 1.0.9
dotnet add package OracleBackgroundSink --version 1.0.9
NuGet\Install-Package OracleBackgroundSink -Version 1.0.9
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OracleBackgroundSink" Version="1.0.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OracleBackgroundSink" Version="1.0.9" />
<PackageReference Include="OracleBackgroundSink" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OracleBackgroundSink --version 1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OracleBackgroundSink, 1.0.9"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OracleBackgroundSink@1.0.9
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OracleBackgroundSink&version=1.0.9
#tool nuget:?package=OracleBackgroundSink&version=1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
OracleBackgroundSink
OracleBackgroundSink is a custom Serilog sink that enables asynchronous background logging directly into an Oracle database using Oracle.ManagedDataAccess.Core.
Features
- Asynchronous logging to Oracle
- Non-blocking background processing
- Optimized for high-throughput scenarios
- Compatible with .NET 8
- Lightweight and easy to integrate
Installation
Install via NuGet:
dotnet add package OracleBackgroundSink
USAGE
using Serilog;
using OracleBackgroundSink;
Log.Logger = new LoggerConfiguration()
.WriteTo.OracleBackgroundSink("your-oracle-connection-string")
.CreateLogger();
Log.Information("This is a test log entry.");
Oracle Table Structure
--------------------------------------------------------
-- DDL for Table LOGS
--------------------------------------------------------
CREATE TABLE "SYSTEM"."LOGS"
( "ID" NUMBER GENERATED ALWAYS AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE ,
"MESSAGE" VARCHAR2(4000 BYTE),
"TEMPLATE" VARCHAR2(4000 BYTE),
"LOG_LEVEL" VARCHAR2(128 BYTE),
"TIMESTAMP" TIMESTAMP (6),
"EXCEPTION" CLOB,
"PROPERTIES" CLOB
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSTEM"
LOB ("EXCEPTION") STORE AS BASICFILE (
TABLESPACE "SYSTEM" ENABLE STORAGE IN ROW 4000 CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
LOB ("PROPERTIES") STORE AS BASICFILE (
TABLESPACE "SYSTEM" ENABLE STORAGE IN ROW 4000 CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) ;
--------------------------------------------------------
-- DDL for Index SYS_C008221
--------------------------------------------------------
CREATE UNIQUE INDEX "SYSTEM"."SYS_C008221" ON "SYSTEM"."LOGS" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSTEM" ;
--------------------------------------------------------
-- Constraints for Table LOGS
--------------------------------------------------------
ALTER TABLE "SYSTEM"."LOGS" MODIFY ("ID" NOT NULL ENABLE);
ALTER TABLE "SYSTEM"."LOGS" ADD PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSTEM" ENABLE;
EXAMPLE 1
------------------------------------------------------------------------------------------------
Program.cs
using Oracle.ManagedDataAccess.Client;
using oracle_sink;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
var connectionString = "User Id=system;Password=XXXXXXX;Data Source=localhost:1521/XEPDB1";
// Create an OracleSink object manually
var oracleSink = new OracleBackgroundSink(connectionString, tableName: "LOGS");
// Configure Serilog to use the OracleSink
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Information()
.WriteTo.Sink(oracleSink)
.CreateLogger();
Log.Information("Test log message in Oracle database.3");
// Hook for graceful shutdown
AppDomain.CurrentDomain.ProcessExit += (s, e) =>
{
Log.Information("Application shutting down. Flushing logs.");
Log.CloseAndFlush();
oracleSink.Dispose();
};
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();
EXAMPLE 2
-------------------------------------------------------------------------------------------
using Oracle.ManagedDataAccess.Client;
using oracle_sink; //replace
using Serilog;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
var connectionString = "User Id=system;Password=XXXXXXXXXX;Data Source=localhost:1521/XEPDB1";
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.OracleLogSink(connectionString, tableName: "LOGS")
.CreateLogger();
Log.Information("Test log message in Oracle database.");
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- Oracle.ManagedDataAccess.Core (>= 23.8.0)
- Serilog (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.