0
votes

I have two console applications A and B. These two projects are hosted as Azure Webjobs. I configured console, rolling file and app. Insights appenders in a common project C, ConfigManager.cs file.

A is calling C.ConfigManager to configure appenders. A.Orchestrator able to log messages to all 3 appenders.

B is also calling C.ConfigManager to configure appenders. B.Orchestrator is able to log messages to console and rolling file appender but not to Application Insights.

All my log4net configurations are pretty much static. I am unable to find what could be the root cause here

2
You should not be using rolling file appender, I think. stackoverflow.com/questions/28800320/…Chetan
I don't see problem with rolling file appender. Please read the issue again. I am not seeing any logs in AI but can view in file and console.Pradeep
TelemetryConfiguration.Active.TelemetryChannel.Flush() is flushing logs to application insights. I am still checking why these logs are not flushed automaticallyPradeep
Hi @Pradeep, did you found any solution for this issue? Because I am also facing the same issue.aryan

2 Answers

0
votes

You can try using internal debug of log4net:

Something like this:

<appSettings>
    <add key="log4net.Internal.Debug" value="true"/>
</appSettings>

then write to a file:

<system.diagnostics>
    <trace autoflush="true">
        <listeners>
            <add 
                name="textWriterTraceListener" 
                type="System.Diagnostics.TextWriterTraceListener" 
                initializeData="C:\users\desktop\log.txt" />
        </listeners>
    </trace>
</system.diagnostics>

Alternative, you can check the version of ApplicationInsights. If its older than AILog4netAppender, then try to upgrade the version.

0
votes

The telemetry data is not sent to application insights immediately, it will batched then send.

So for console app, you'd better add some sleep time like System.Threading.Thread.Sleep(1000) before console app exits.

Hope it helps.