Search
 
SCRIPT & CODE EXAMPLE
 

SQL

Serilog Table Configurations for MSSQLSERVER SINK

#region Error
    var sinkOptionsError = new MSSqlServerSinkOptions
    {
        AutoCreateSqlTable = true,
        EagerlyEmitFirstEvent = true,
        SchemaName = "dbo",
        TableName = "LogError",
    };
    var columnErrorOptions = new ColumnOptions
    {
        AdditionalColumns = new Collection<SqlColumn>
        {
            new SqlColumn { ColumnName = "Application", PropertyName = "Application", DataType = System.Data.SqlDbType.VarChar, DataLength = 100, AllowNull = true},
            new SqlColumn { ColumnName = "SourceContext", PropertyName = "SourceContext", DataType = System.Data.SqlDbType.VarChar, DataLength = 100, AllowNull = true}
        },
    };
    columnErrorOptions.Store.Remove(StandardColumn.MessageTemplate);
    columnErrorOptions.Store.Remove(StandardColumn.Properties);
    columnErrorOptions.Store.Add(StandardColumn.LogEvent);
    columnErrorOptions.Level.DataLength = 12;
    columnErrorOptions.TimeStamp.ConvertToUtc = true;
    #endregion

    #region Info
    var sinkOptionsInfo = new MSSqlServerSinkOptions
    {
        AutoCreateSqlTable = true,
        EagerlyEmitFirstEvent = true,
        SchemaName = "dbo",
        TableName = "LogInfo"
    };
    var columnInfoOptions = new ColumnOptions
    {
        AdditionalColumns = new Collection<SqlColumn>
        {
            new SqlColumn { ColumnName = "Application", PropertyName = "Application", DataType = System.Data.SqlDbType.VarChar, DataLength = 100, AllowNull = true},
            new SqlColumn { ColumnName = "SourceContext", PropertyName = "SourceContext", DataType = System.Data.SqlDbType.VarChar, DataLength = 100, AllowNull = true}
        },
    };
    columnInfoOptions.Store.Remove(StandardColumn.MessageTemplate);
    columnInfoOptions.Store.Remove(StandardColumn.Properties);
    columnInfoOptions.Store.Remove(StandardColumn.Exception);
    columnInfoOptions.Store.Add(StandardColumn.LogEvent);
    columnInfoOptions.Level.DataLength = 12;
    columnInfoOptions.TimeStamp.ConvertToUtc = true;
    #endregion
    #region Request
    var sinkOptionsRequest = new MSSqlServerSinkOptions
    {
        AutoCreateSqlTable = true,
        EagerlyEmitFirstEvent = true,
        SchemaName = "dbo",
        TableName = "LogRequest",
    };
    var columnRequestOptions = new ColumnOptions
    {
        AdditionalColumns = new Collection<SqlColumn>
        {
            new SqlColumn { ColumnName = "RequestMethod", PropertyName = "RequestMethod", DataType = System.Data.SqlDbType.VarChar, DataLength = 50, AllowNull = true},
            new SqlColumn { ColumnName = "RequestPath", PropertyName = "RequestPath", DataType = System.Data.SqlDbType.VarChar, DataLength = 500, AllowNull = true},
            new SqlColumn { ColumnName = "StatusCode", PropertyName = "StatusCode", DataType = System.Data.SqlDbType.VarChar, DataLength = 50, AllowNull = true},
            new SqlColumn { ColumnName = "Elapsed", PropertyName = "Elapsed", DataType = System.Data.SqlDbType.Float, AllowNull = true},
            //activating these columns will break saving to database ... so don't!!!
            //new SqlColumn { ColumnName = "ClientIp", PropertyName = "ClientIp", DataType = System.Data.SqlDbType.VarChar, DataLength = 50, AllowNull = true },
            //new SqlColumn { ColumnName = "ClientAgent", PropertyName = "ClientAgent", DataType = System.Data.SqlDbType.VarChar, DataLength = 100, AllowNull = true },
            new SqlColumn { ColumnName = "Application", PropertyName = "Application", DataType = System.Data.SqlDbType.VarChar, DataLength = 100, AllowNull = true},
        },
    };
    columnRequestOptions.Store.Remove(StandardColumn.MessageTemplate);
    columnRequestOptions.Store.Remove(StandardColumn.Exception);
    columnRequestOptions.Store.Remove(StandardColumn.Level);
    columnRequestOptions.Store.Remove(StandardColumn.Properties);
    columnRequestOptions.Store.Add(StandardColumn.LogEvent);
    columnRequestOptions.Level.DataLength = 12;
    columnRequestOptions.TimeStamp.ConvertToUtc = true;
    #endregion
Comment

PREVIOUS NEXT
Code Example
Sql :: call procedure in wordpress 
Sql :: how to get one year old query from plan cache 
Sql :: SQL Query Records Using Dates 
Sql :: trncate table with relationships 
Sql :: sqlite show table headers 
Sql :: PDOException: SQLSTATE[HY093]: Invalid parameter numb 
Sql :: search starting with mysql 
Sql :: formatting code with SQL Developer 
Sql :: leftjoin in sql 
Sql :: Windows internal database connection 
Sql :: suse stop MySQL 
Sql :: less than date query sqlachemy 
Sql :: row_number equivalent MS Access for sequential id By Group (2) 
Sql :: AND Operator (AND) 
Sql :: PSQL qith variables 
Sql :: how to find shortest and longest name in sql 
Sql :: database name 
Sql :: how to remove quotes from a string in ssis load file 
Sql :: spring Flyway Teams Edition or MySQL upgrade required: MySQL 5.5 is no longer supported by Flyway Community Edition, but still supported by Flyway Teams Edition. 
Sql :: migration to create a gender in the database table 
Sql :: how do you execute the fragment or sqlBatch using scriptdom 
Sql :: why we have to set the password for my sql server 
Sql :: select from another database 
Sql :: proc sql not in working 
Sql :: ring MySQL get the inserted row id 
Sql :: SQL Multiplication Operator 
Sql :: sqlc yml settings version 1.14 
Sql :: how to combine rows in sql server procedure 
Sql :: How To Execute SQL Select Statements 
Sql :: mysql does sentance contain word 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =