Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging to local file with Application Insights

Can Application Insights log to a local file in the application directory? We have an implementation where each customer who uses our software needs to have a separate instance of Application Insights. Our client software relies on a call to a web service to get the Instrumentation Key. We are running into some issues where we need logging before we get the Instrumentation key.

Can Application Insights log to the local file system? Or can it cache logs such that they can be explored? Thanks.

like image 516
NSouth Avatar asked Mar 04 '23 16:03

NSouth


1 Answers

You can write own channel for this purpose. Implement ITelemetryChannel and use its Send method to write telemetry to local disk.

class FileChannel : ITelemetryChannel
{
    public MyChannel()
    {
    }

    public bool? DeveloperMode { get; set; }
    public string EndpointAddress { get; set; }

    public void Dispose()
    {

    }

    public void Flush()
    {

    }

    public void Send(ITelemetry item)
    {
        // logic to write item to file..
    }
}
like image 50
cijothomas Avatar answered Mar 19 '23 15:03

cijothomas