I have an existing application which I'm moving from Azure Web Apps to Service Fabric. I have lots of application specific logging code using Microsoft's Microsoft.Extensions.Logging.ILogger abstraction which given the appropriate provider (console, azure web app) gives me console and LogStream output. Works great.
What's the easiest way to view these application logs when working with Service Fabric?
You can use EventFlow to capture the logs and forward to the target storage like ApplicationInsights. You could still use the existing ILogger or replace it to use ETW.
For example, if you want write your logs to trace and them capture the trace information to forward to another storage you have to:
Add reference to the package Microsoft.Diagnostics.EventFlow
Create the eventFlowConfig.json file to define the inputs and outputs:
{
"inputs": [
{
"type": "Trace",
"traceLevel": "Warning"
}
],
"outputs": [
{
"type": "ApplicationInsights",
"instrumentationKey": "00000000-0000-0000-0000-000000000000"
}
]
}
Wrap you webapp initialization with EventFlow pipeline:
using (var pipeline = DiagnosticPipelineFactory.CreatePipeline("eventFlowConfig.json"))
{
//App initialization goes here
System.Diagnostics.Trace.TraceWarning("EventFlow is working!");
Console.ReadLine();//this will be replaced by your webHost start
}
You can have many inputs, so if you also want to monitor the ETW events, you could add it on the input list as well.