I am trying to create a log table using Serilog but it does not insert into the table with no errors .
connection string is right but I still don't understand why it dose not insert please help me to fix this problem
I am a beginner with logging so please give me answer with details
namespace QueuingSystemApp.Models
{
public class HelperDB
{
private static readonly ILogger Errorlog;
private static readonly ILogger Warninglog;
private static readonly string ConnectionString =
ConfigurationManager.ConnectionStrings["QueueingSystemEntities"].ConnectionString.ToString();
static HelperDB()
{
Consollog = new LoggerConfiguration().WriteTo.Debug().CreateLogger();
Errorlog = new LoggerConfiguration()
.MinimumLevel.Error()
.WriteTo.MSSqlServer(ConnectionString, "Serilogs")
.CreateLogger();
Warninglog = new LoggerConfiguration()
.MinimumLevel.Warning()
.WriteTo.MSSqlServer(ConnectionString, "Serilogs")
.CreateLogger();
}
public static void WriteError( string message, int userid , int actionlog)
{
//Error - indicating a failure within the application or connected system
Errorlog.Write(LogEventLevel.Error, message, "{UserID}{LogAction}", userid,actionlog );
}
public static void WriteWarning(Exception ex, string message)
{
//Warning - indicators of possible issues or service / functionality degradation
Warninglog.Write(LogEventLevel.Warning, ex, message);
}
}
}
question from:
https://stackoverflow.com/questions/65902020/serilog-not-inserting-logs-into-database-table 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…