ApplicationInsights-dotnet
ApplicationInsights-dotnet copied to clipboard
Package update replaces log configuration in app.config
Hello,
This is an old issue that happens every time one update Microsoft.ApplicationInsights.NLogTarget. app.config rules are replaced with default ones.
I've just updated from 2.6.4 to 2.8.2 and got this change.
Complexity here is that we want to remove logger from config on uninstall:
https://github.com/Microsoft/ApplicationInsights-dotnet-logging/blob/93ad4a8a46965d95654fe1f962df74c3bb792a79/src/NLogTarget/app.config.uninstall.xdt#L10-L12
NuGet will call uninstall first and then install the never package. There is no indication given that uninstall is a part of an upgrade.
One solution may be to switch attribute Enable
to false on uninstall instead. But this will not help you =).
Do you have better suggestion on how to fix it?
@karann-msft , I found your name in NuGet repo. Can you please confirm that there is no way to detect whether uninstall was called for upgrade or by itself?
@SergeyKanzhelev - no, its not possible to differentiate between those two. cc: @jainaashish
So we either have a bug on in-proper clean up of a config or a bug on erasing customizations. I think first is more critical as not erasing listeners may be damaging for the application and hard to discover. When erasing of customizations is easily discoverable via and source control system.
Closing the issue unless there are better proposals. @Muhomorik thank you for reporting and using Application Insights!
This problem is obviously solved by nlog and apparently there is a way to figure out if this is an upgrade:
PM> Update-Package Nlog.Config
... etc...
File Conflict
File 'NLog.config' already exists in project 'VbWinFormsNlog'. Do you want to overwrite it?
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "N"): N
When erasing of customizations is easily discoverable via and source control system.
Not how a source control should be used. Imaging solution with 20 projects.
I think first is more critical as not erasing listeners may be damaging for the application and hard to discover.
Yes, but you are enabling listeners on TRACE level. From docs: Trace | Begin method X, end method X etc
Most programs have checkbox "allow reporting errors etc", but this is completely different. This is like possible GDRP violation because debug data will be send.
Also, I am talking about "Classic desktop". Means that you can't update all installations that quickly.
Plus, I believe the default config for loggers is not to create any listeners at all.
@karann-msft, @jainaashish any suggestions here? Do you know how NLog package does it?
NLog also hasn't solved. NLog.config
was modified after first installation so when we uninstalled as part of update, we left it behind. Now as part of install NuGet sees the file already exists so it ask to overwrite before proceeding.
If NLog.Config
wasn't modified before then it would not have shown this overwriting option. So simply install NLog.config
and try to update.
Another poor soul bitten by this "feature":
https://usefulscripts.wordpress.com/2020/05/10/use-application-insights-logging-adapters-with-nlog-c-console-application/
Btw. the NLog.config
-nuget-package should be avoided at all costs. It will actually give you more headache (After Microsoft introduced <packagereferences>
in csproj-files).
This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Stil think this "feature" should be removed. The idea was it should help with initial setup, but actually it is causing a lot of pain during deployment with unexpected surprises. Don't like unexpected surprises.
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.
Still bad behavior to modify config-files on nuget-package install.
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.