I was going through several blog posts at stackoverflow and programmers and I am still a bit confused. You can install NLog (or some other logging lib) and start logging quite fast and then you can install the application insights and an adapter to actually gather the data into the Azure Application Insights.
Is it really necessary to use two approaches (NLog combined with AppInsights)? What if we simply use the AppInsight's TelemetryClient to log and trace. If I want to go fancy, I can wrap it with an interface, so I can easily change it later on. I can even wrap it in Common.Logging to be even fancier. (I would be really fancy there.)
Are there any benefits of using both NLog and Application Insights? Do you think logging into a "local" database and into Azure is superfluous? Are there any drawbacks of using only Application Insights for both logging and tracing (latency, too expensive to call either time wise or money wise)?
AppInsight's example - Imagine you have a DI container somewhere:
ILog.cs
public interface ILog
{
void Exception(Exception ex);
}
TelemetryClientLog.cs
public class TelemetryClientLog : ILog
{
private readonly TelemetryClient telemetryClient = null;
public TelemetryClientLog(TelemetryClient telemetryClient)
{
this.telemetryClient = telemetryClient;
}
public void Exception(Exception ex)
{
this.telemetryClient.TrackException(ex);
}
}
StarWars.cs
// somewhere in a code far far away with an injected logger
try
{
this.CallJedi();
}
catch(LightSaberException lse)
{
// log implements ILog interface, look above
this.log.Exception(lse);
}