-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finalize logging analyzers #36064
Comments
Where are these analyzers published? |
Will they work on VS2015? |
@pakrym, still no plans to release this? |
No, not in 2.1 |
😢 |
@pakrym - are we shipping them in "experimental" form so that people can easily try them out? I thought I heard someone say that the other day. |
Yes, we would continue to ship them in the same form they are now, but wouldn't do the same thing we did with MVC and EF analyzers (reference from packages themselves) |
I think these analyzers should be a little more extensive than they are now. It would also be great if they supported structured logging templates. The structured message analyzer rule can be 'none' severity by default and only enabled if users want them. |
any updates on this? |
@pakrym any updates on this one? can you please point me to the current nuget feed used for nightly builds? I didnt find any info on this in the readme and the link above does not work (vs shows no packages) and the link to the package asks for credentials. |
@anurse might have more information on this. |
I believe the packages should be on the I don't have specific updates on the progress here, but it will be considered as part of 5.0 planning. |
Could this tie in to the analyzer effort you're working on @bartonjs @jeffhandley ? These are analyzers currently produced in extensions (though the logging stuff is now owned by the runtime) that we don't currently ship (they're marked as non-shipping packages) but would be useful for anyone using Microsoft.Extensions.Logging. |
Hey @anurse - sorry for the delayed response. Our review process is currently fairly narrow as we were only planning to ship a small set of analyzers for now and dial it up later, and I don't expect we'll add any more analyzers into the .NET Libraries team's backlog for 5.0. Were you just thinking you want to get these into the backlog, or did you want to contribute them into a productized shipping vehicle? |
Would this issue be at all related to Suchiman/SerilogAnalyzer#15 ? |
Hey, is there any chance that we could publish a preview version of the logging analyzers on NuGet? I’m totally fine with the current feature set and would just like to consume them, ideally without having to rely on a separate nightly feed. |
I tested out the logging analyzer, and seems like it mostly has Information level diagnostics (3 of them I think), and the one warning level diagnostics is checking for mismatch in arguments provided in the message template. This is a kind of analytics already provided by the source generator we are working on in issue #36022. So it makes sense to defer shipping this analyzer to after until we first have the logging generator in. |
@shirhatti should we close this given that we have logging generator now? or is this something you are still interested to include as part of 6.0? UPDATE: Since there are use cases in here not addressed by the source generator work, makes sense to keep this issue open but we reduced its priority. |
The source generator (if used) solves zero problems I encounter in logging, but the analyzers (if used) would solve... pretty much every problem I encounter. Nearly 100% of the libraries we use get logging wrong, because the people writing the logging in those libraries have no idea that log templates are supposed to be constant. Why not solve the actual problem in all the existing dotnet versions via simple analyzers, and then work on whatever issue the code generation is supposed to solve for the future? Nothing we use is going to be touching .NET 6, I haven't even seen any code using .NET 5, so abandoning improvements on the existing developer experience to aid developers that don't yet exist seems way out of touch here. |
@Kesmy That sounds like a +1 for the logging analyzers. Thanks for letting us know this is still very important to you. @ericstj @maryamariyan lets discuss to see if we can come up with a plan. |
I want to add that this is also a case where "good enough" is probably going to be good enough. There exists a I know there was an early post that suggested that structured logging analyzers should be |
Thanks for your feedback, keeping this issue open to track adding an analyzer for logging as well. |
API Review notes
|
Are we doing a fixer from |
we're adding the analyzer as an analyzer in the SDK so my assumption is that the source generator wont be available in all cases that this analyzer suit is available for, and the fixer wouldn't be able to use the source gen. But would be good to use the source generator for adding the fixer. cc: @ericstj |
We'll add the fixers in the 7.0 timeframe. |
Does that mean that the analyzers are on track for 6.0? That's great news! We've been hit by the issue from diagnostic 5 a few times in production so this will help a lot. Thanks for following up with this @maryamariyan! |
Yes :) Here's a link to the merged PR dotnet/roslyn-analyzers#5244 |
Closing this issue as fixed and opened dotnet/roslyn-analyzers#7241 to track adding the fixers. |
Are these analyzers available prior to .NET 6? If not, we're probably not going to be able to use them for another decade. |
They have been added to the SDK so you can use them when targeting any framework and running on the latest SDK. The analyzers are also available out-of-band in https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers. You can even try out a nightly build of those today: https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet6&package=Microsoft.CodeAnalysis.NetAnalyzers&protocolType=NuGet&version=6.0.0-preview7.21378.5&view=overview |
Scope for analyzer
With these set of analyzers the the developers would be able to use the logging APIs at runtime in a more guided way.
For example, this is related to
LoggerExtensions
, APIs such asBeginScope
,LogTrace
,LogDebug
, etc. Also APIs such asLoggerMessage
Define
andDefineScope
.List of proposed diagnostics
Usage samples:
DIAG_1
: Use PascalCase for log message tokensDIAG_2
: For improved performance, use pre-compiled log messages insteadDIAG_3
: Numerics should not be used in logging format stringDIAG_4
: Logging format string should not be dynamically generatedThis would be for
LogTrace
and similar APIs.DIAG_5
: Logging format string parameter count mismatchDIAG_5
? when this code snippet runs we get this exception thrown at runtime:Link to code
The latest PR is available at dotnet/roslyn-analyzers#5244
The code was originally prototyped as preview in https://github.com/dotnet/extensions/tree/master/src/Logging/Logging.Analyzers/src but has not yet been shipped analyzers.
Original Description
Consider adding analyzers for
DefineMessage
Reference analyzers from our projects
Decide how are they going to be shipped
/cc @glennc
The text was updated successfully, but these errors were encountered: