Created
March 31, 2020 13:01
-
-
Save syron/65f5102671b56672185dfa8943ffc035 to your computer and use it in GitHub Desktop.
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
var logapiurl = "http://localhost/im-demo/logapi/api/"; | |
var settings = new NodiniteLogEventSettings() | |
{ | |
LogAgentValueId = 20, | |
EndPointDirection = 0, | |
EndPointTypeId = 0, | |
EndPointUri = "Nodinite.Serilog.EventHubSink.Tests.Serilog", | |
EndPointName = "Nodinite.Serilog.EventHubSink.Tests", | |
ProcessingUser = "NODINITE", | |
ProcessName = "Nodinite.Serilog.EventHubSink.Tests", | |
ProcessingMachineName = "NODINITE-DEV", | |
ProcessingModuleName = "DOTNETCORE.TESTS", | |
ProcessingModuleType = "DOTNETCORE.TESTPROJECT" | |
}; | |
// x-ms-client-tracking-id | |
string correlationIdValue = string.Empty; | |
try | |
{ | |
StringValues correlationId; | |
var clientTrackingId = Request.Headers.TryGetValue("x-ms-client-tracking-id", out correlationId); | |
correlationIdValue = correlationId.First(); | |
} | |
catch { | |
correlationIdValue = Guid.NewGuid().ToString(); | |
} | |
ILogger log = new LoggerConfiguration() | |
.WriteTo.NodiniteApiSink(logapiurl, settings) | |
.CreateLogger() | |
.ForContext("ApplicationInterchangeId", correlationIdValue) | |
.ForContext("CustomerId", 123) | |
.ForContext("Body", body); | |
log.Information("Request received"); | |
try | |
{ | |
body = body.ToLower(); | |
log = log.ForContext("body", body); | |
log.Information("Body transformed, sending response"); | |
} | |
catch (Exception ex) | |
{ | |
log.Error($"Failed to transform body. Exception={ex.Message}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment