- 2 minutes to read
1. Code
var folder = "{Your Folder}";
var settings = new NodiniteLogEventSettings()
{
LogAgentValueId = 42,
EndPointDirection = 0,
EndPointTypeId = 0,
EndPointUri = "Nodinite.Serilog.FileSink.Tests.Serilog",
EndPointName = "Nodinite.Serilog.FileSink.Tests",
ProcessingUser = "NODINITE",
ProcessName = "Nodinite.Serilog.FileSink.Tests",
ProcessingMachineName = "NODINITE-DEV",
ProcessingModuleName = "DOTNETCORE.TESTS",
ProcessingModuleType = "DOTNETCORE.TESTPROJECT"
};
ILogger log = new LoggerConfiguration()
.WriteTo.NodiniteFileSink(folder, settings)
.CreateLogger();
2. Appsettings.json
{
"Serilog": {
"Using": [ "Nodinite.Serilog.FileSink" ],
"WriteTo": [
{
"Name": "NodiniteFileSink",
"Args": {
"Folder": "",
"Settings": {
"LogAgentValueId": 42,
"EndPointName": "Nodinite.Serilog.FileSink.Tests",
"EndPointUri": "Nodinite.Serilog.FileSink.Tests.Serilog",
"EndPointDirection": 0,
"EndPointTypeId": 86,
"OriginalMessageTypeName": "https://ACME.com/Customers/1.0#Batch",
"ProcessingUser": "NODINITE",
"ProcessName": "Nodinite.Serilog.FileSink.Tests",
"ProcessingMachineName": "NODINITE-DEV",
"ProcessingModuleName": "DOTNETCORE.TESTS",
"ProcessingModuleType": "DOTNETCORE.TESTPROJECT"
}
}
}
]
}
}
var configuration = new ConfigurationBuilder()
// NOTE: If required, make sure to set the base path, for example:
// .SetBasePath(Directory.GetCurrrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
Logger log = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();