I'm trying to log the information and errors to the oracle database using serilog
I see only examples for MS SQL Server. I created this config using that as an example. I don't see any blog or info about the oracle option.
Please help
here are the config and program files.
Appsetting.json
"Serilog": {
"Using": [ "Serilog.Sinks.Oracle" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Error",
"Microsoft.AspNetCore.Mvc": "Warning"
}
},
"WriteTo": [
{
"Name": "Oracle",
"Args": {
"connectionString": "xxx",
"tableName": "Log",
"autoCreateSqlTable": false,
"columnOptionSection": {
"removeStandartColumns": [ "Id", "Message", "MessageTemplate", "Level", "TimeStamp", "Exception", "Properties" ],
"customColumns": [
{
"ColumnName": "Application",
"DataType": "nvarchar",
"DataLength": "10"
},
{
"ColumnName": "Source",
"DataType": "nvarchar",
"DataLength": "10"
},
{
"ColumnName": "Message_TXT",
"DataType": "nvarchar",
"DataLength": "4000"
},
{
"ColumnName": "TimeStamp_Dt",
"DataType": "date"
},
]
}
}
}
Program.cs
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.Enrich.FromLogContext()
.CreateLogger();
LogContext.PushProperty("Application", "TEST");
LogContext.PushProperty("Source_Txt", "SERILOG");
LogContext.PushProperty("Message_txt", message);
LogContext.PushProperty("TimeStamp_DT", DateTime.Now);
logger.Information(message);
It doesn't throw any error and does not log any info to the database.
This is an experimental code, please use it on your own risk.
You need to create table manually using below script. I had followed this for reference.