Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Microsoft.ApplicationInsights.WorkerService - Log4NetAppender Issue #994

Closed
balakrishnanj opened this issue Sep 26, 2019 · 1 comment
Closed
Labels
question worker for workerservice sdk

Comments

@balakrishnanj
Copy link

balakrishnanj commented Sep 26, 2019

I'm using Microsoft.ApplicationInsights.WorkerService to push telemetry from .net core 2.2 windows worker service to application insights portal. I'm using Log4net third party provider for logging. Using the worker service package, I'm able to see the dependencies/SQL calls in application insights portal, but trace statements logged using log4net provider are missing in the portal. Upon debugging, I noticed log4net trace telemetry are marked as 'Unconfigured' and Instrumentation key is missing.

**Application Insights Telemetry (unconfigured)**: {"name":"Microsoft.ApplicationInsights.Message","time":"2019-09-26T16:40:51.9205695Z","tags":{"ai.cloud.roleInstance":"","ai.operation.id":"f584d91a7755cc43b7539aaadb43706f","ai.operation.parentId":"|f584d91a7755cc43b7539aaadb43706f.f61b1953f331a24a.","ai.operation.name":"Lifecycle Status Service","ai.internal.sdkVersion":"log4net:2.12.0-752"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"2019-09-26 12:40:51,920 [8] INFO 0 (null) > - Test Jithesh","severityLevel":"Information","properties":{"ClassName":"?","MethodName":"?","FileName":"?","LineNumber":"?","LoggerName":"Identifi.Network.LifeCycleStatus.Host.LifeCycleStatusService","ServiceRequestId":"0","Domain":"NOT AVAILABLE","Identity":"NOT AVAILABLE","ThreadName":"8"}}}}

But it works when adding a dependency

Application Insights Telemetry: {"name":"Microsoft.ApplicationInsights.Dev.7ac95097cd964541bb60e2243fb4cfb1.RemoteDependency","time":"2019-09-26T16:43:13.7914345Z","iKey":"7ac95097-cd96-4541-bb60-e2243fb4cfb1","tags":{"ai.application.ver":"1.0.0.0","ai.cloud.roleInstance":"5CD8279JVL","ai.operation.id":"f584d91a7755cc43b7539aaadb43706f","ai.operation.parentId":"|f584d91a7755cc43b7539aaadb43706f.f61b1953f331a24a.","ai.internal.sdkVersion":"rdddsc:2.11.0-21563","ai.internal.nodeName":""},"data":{"baseType":"RemoteDependencyData","baseData":{"ver":2,"name":"HEAD /provider-verification-source-dv","id":"|f584d91a7755cc43b7539aaadb43706f.8726f2d0ceccef48.","data":"","duration":"00:00:00.0787428","resultCode":"200","success":true,"type":"Http","properties":{"DeveloperMode":"true","_MS.ProcessedByMetricExtractors":"(Name:'Dependencies', Ver:'1.1')"}}}}

I following the steps mentioned in https://docs.microsoft.com/en-us/azure/azure-monitor/app/worker-service article. Could you please let me know if I'm missing anything?

@cijothomas
Copy link
Contributor

The WorkerService SDK only configures one logging adaptor - iLogger, not anything else.

Log4NetAppender internally relies on TelemetryConfiguration.Active which is not setup by WorkerService.

You can make it work by setting TelemetryConfiguration.Active.InstrumentationKey. However, it (log4net logs) won't have the same config as other telemetry.

@cijothomas cijothomas added question worker for workerservice sdk labels Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question worker for workerservice sdk
Projects
None yet
Development

No branches or pull requests

2 participants