Created
May 3, 2020 08:18
-
-
Save sametoz/eee1ce69c7223c278670fa96c1f85d19 to your computer and use it in GitHub Desktop.
v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main(string[] args) | |
{ | |
var sinkOpts = new SinkOptions { TableName = "_Log", AutoCreateSqlTable = true, BatchPostingLimit = 10 }; | |
//ColumnOptions: Veritabanı tablosunun özellikleri burada belirlenir. | |
//default oluşturulan sütunlar çıkartılabilir, veya yenileri eklenebilir. | |
var columnOptions = new ColumnOptions | |
{ | |
AdditionalColumns = new Collection<SqlColumn> | |
{ | |
new SqlColumn | |
{ColumnName = "UserName", PropertyName = "UserName", DataType = SqlDbType.NVarChar, DataLength = 64}, | |
new SqlColumn | |
{ColumnName = "ApiPath", PropertyName = "ApiPath", DataType = SqlDbType.NVarChar, NonClusteredIndex = true} | |
} | |
}; | |
//Serilog'un sunduğu ve işimize yaramayan iki sütunu kaldırıyorum. | |
columnOptions.Store.Remove(StandardColumn.MessageTemplate); | |
columnOptions.Store.Remove(StandardColumn.Properties); | |
Log.Logger = new LoggerConfiguration() | |
.WriteTo.MSSqlServer( | |
connectionString: appSettings.GetConnectionString("DB"), | |
sinkOptions: sinkOpts, | |
columnOptions: columnOptions, | |
restrictedToMinimumLevel: LogEventLevel.Error | |
).CreateLogger(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment