We have a .net framework 4.5.1 MVC web application. We want to log information to the console when the application runs. Obviously when running the app in my local computer, I can see the output window and my logs are there. But what about when it's deployed to Azure? How do I see my logs? Where in Azure should I log to (or what are my options)?
I tried:
Console.WriteLine("🔥 Console.WriteLine");
System.Diagnostics.Trace.WriteLine("🔥 Trace.WriteLine");
System.Diagnostics.Trace.TraceInformation("🔥 Trace.TraceInformation");
System.Diagnostics.Trace.TraceWarning("🔥 Trace.TraceWarning");
System.Diagnostics.Trace.TraceError("🔥 Trace.TraceError");
But I can't find my logs anywhere except in log streaming, which isn't what I'm looking for since that only works for 12 hours.
I tried to repro in my local and i can able to see my logs through:
.Download Logs from Kudu console
From Diagnostic setting i have enabled the following to see the logs
From Application insight we can see below data for our application
And , Using KuduConsole we can download the log files . From app service >advance tools> click on GO
After open kudu Go to **Debug console**
and from here we can download our logs from the Left side as marked:
But I can't find my logs anywhere except in log streaming, which isn't what I'm looking for since that only works for 12 hours.
Also Thanks to Amit Apple posting your suggestion as an answer to help other community members.
"You can do this by setting an App setting called DIAGNOSTICS_TEXTTRACETURNOFFPERIOD
to a value (much) greater than 12 * 60 * 60 * 1000
which is 12 hours in milliseconds."
as mentioned in GItHub
For further information Please refer this SO thread How can I view console or trace output in an azure app service? Console.WriteLine or Trace.TraceError