Comments (13)
Okay, give it a deep look. There are 2 issues.
- The instructions to enable self-diagnostics for ApplicationInsights.Kubernetes needs to be updated because of the way config logger provider changes. @PeterRockstars basically nailed the solution. I'll update the document to reflect the changes. One side note is that in HomeController, dependency injection upon
ILogger<>
thanILoggerFactory
is more recommended:
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
_logger.LogTrace("TRACE");
}
That should address @mumarniaz 's issue.
- @PeterRockstars is looking for more logs - logs from the real application insights library. If I understand it correct, you are looking for additional entries like it below:
Application Insights Telemetry: {"name":"Microsoft.ApplicationInsights.Dev.5789ad108b394f8a88dc632d1342d5e0.Message","time":"2018-01-03T23:48:52.4627170Z","iKey":"i-do-not-tell-you-my-ikey","tags":{"ai.application.ver":"1.0.0.0","ai.user.id":"ldoLQ","ai.operation.parentId":"|c2390d17-42b31bbca592ecb8.","ai.operation.id":"c2390d17-42b31bbca592ecb8","ai.cloud.roleInstance":"my-machine-name","ai.internal.sdkVersion":"aspnet5c:2.1.1","ai.location.ip":"::1","ai.internal.nodeName":"xxx","ai.operation.name":"GET /lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2","ai.session.id":"1rbWZ"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"The file /lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 was not modified","severityLevel":"Information","properties":{"Path":"/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2","AspNetCoreEnvironment":"Development","CategoryName":"Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware","DeveloperMode":"true","{OriginalFormat}":"The file {Path} was not modified"}}}}
I think that is totally reasonable during the diagnostic session, you want to see all the way till temelemtry is actually sent, that is, however, not within control of AI.Kubernetes. To make the scenario work in ASP.NET Core 2.0, this work item needs to be addressed first in AI.Aspnetcore:
microsoft/ApplicationInsights-aspnetcore#536 as an active work item.
from applicationinsights-kubernetes.
Perhaps (as this document is a draft from back in May) this API has changed.
I found this article that suggests that your ConfigureLogging line would be changed to:
.ConfigureLogging(f => f.AddConsole(), Microsoft.Extensions.Logging.LogLevel.Trace)
... and you can choose from log level values here.
[Edit: Formatting]
from applicationinsights-kubernetes.
Thanks @d3r3kk
But this won't work because ConfigureLogging
fucntion is expecting only one parameter of type Action
from applicationinsights-kubernetes.
In ASP.NET core 2.0, it looks like ConfigureLogging has changed from taking Action<ILoggingFactory>
to
Action<ILoggingBuilder>.
Here is the new AddConsole method
https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.consoleloggerextensions.addconsole?view=aspnetcore-2.0#Microsoft_Extensions_Logging_ConsoleLoggerExtensions_AddConsole_Microsoft_Extensions_Logging_ILoggingBuilder_
You should be able to do this:
.ConfigureLogging(f => f.AddConsole(Microsoft.Extensions.Logging.LogLevel.Trace))
from applicationinsights-kubernetes.
@brahmnes That doesn't work, as AddConsole(ILoggerFactory, LogLevel) takes an ILoggerFactory, not an ILoggingBuilder..
I'm struggling with the same thing. How do I get to the ILoggerFactory?
from applicationinsights-kubernetes.
This seems to work, sort-of:
.ConfigureLogging(builder => builder
.SetMinimumLevel(LogLevel.Trace)
.AddConsole())
It gives me trace output when I do this:
public HomeController(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<HomeController>();
_logger.LogTrace("TRACE");
}
But it doesn't show any of the App Insights logging shown in the example. Curiously, I do see that output in the debug window in Visual Studio.
from applicationinsights-kubernetes.
Did you add the call to UseApplicationInsights()?
from applicationinsights-kubernetes.
@brahmnes Yes, I did.
It seems that in this line:
ILoggerFactory loggerFactory = (ILoggerFactory)services.FirstOrDefault(s => s.ServiceType == typeof(ILoggerFactory))?.ImplementationInstance;
The ImplementationInstance field is null
from applicationinsights-kubernetes.
Hi Peter,
Application Insights needs to be configured with the LoggerFactory, otherwise ILogger isn't aware of Application Insights. Here is a related post: https://stackoverflow.com/questions/45022693/using-application-insights-with-iloggerfactory
The extension method AddApplicationInsights is in Microsoft.ApplicationInsights.AspNetCore
from applicationinsights-kubernetes.
There are break changes in the configuration settings for ASP.NET Core 2.0. We shall update the library to support it better. I'll look into this issue post 1.0.0-beta2
from applicationinsights-kubernetes.
@xiaomi7732 Thanks for the deep look, glad we got it figured out. And you're absolutely right on point 2, that is what I was looking for.
from applicationinsights-kubernetes.
@PeterRockstars Thank you for the confirm!
from applicationinsights-kubernetes.
Guys, thanks for raising the issue. The wiki has been updated to provide an example for ASP.NET Core 2.0 Web Apps to enable self-diagnostics.
https://github.com/Microsoft/ApplicationInsights-Kubernetes/wiki/%5BAdvanced%5D-How-to-enable-self-diagnostics-for-ApplicationInsights.Kubernetes
I am closing this issue since there is no more action could be taken in this repo. Please keep an eye on the issue of AI.AspNetCore mentioned above.
from applicationinsights-kubernetes.
Related Issues (20)
- [Investigation] Make calling into ExecuteAsync idempotent HOT 2
- Compliance: Unit test SDK depends on Newtonsoft.Json 9.0.1 HOT 2
- AKS no telemetry HOT 3
- Upgrade KubernetesClient to >= 10.0.16 to remove dependency on System.IO.Abstractions HOT 16
- backlog
- Add wiki for supporting Azure Function in K8s HOT 1
- Use AKS instead of local kubernetes - How HOT 4
- No insight output as indicated in Zero Code light up Example HOT 4
- Can I use DefaultAzureCredential with Zero User Code Lightup? HOT 5
- Enhancement: Capture container image name HOT 6
- No container id found by container id providers after AKS upgrade 1.23->1.25 HOT 15
- Investigation: Using a label to locate the current container HOT 1
- Decouple Enhancement and container readiness HOT 2
- Cannot get pod info because of proxy configuration HOT 9
- As of now the package doesn HOT 1
- As of now the package doesn't seem to add the properties anymore? HOT 3
- Can't register Enrichers when using KeyedServices HOT 1
- Upgrade of `KubernetesClient` dependency HOT 17
- how to customize k8s properties name HOT 3
- Warning in pod logs re failed to get container id HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applicationinsights-kubernetes.