-
Notifications
You must be signed in to change notification settings - Fork 146
Configuration in sink is incompatible with Azure Functions V2 #108
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
Comments
Thanks for the note 👍 Ideally, we should drop any references to Any help/PRs appreciated. Cheers! |
I may tackle this one, it just became a blocking issue migrating our V1 Functions to V2. (Edit: I deleted an earlier comment stating that Functions V1 were dependent on Microsoft.Extensions.Configuration 1.0.0 ... that was incorrect.) |
@nblumhardt I've had a chance to go through the code in detail. Multi-targeting is going to be a challenge because Inline conditionals would generally result in two complete side-by-side copies of a couple of top-level classes that could be used by both targets, and it would require quite a few supporting classes that would be completely target-specific (for both targets). Additionally, given that the preferred Since inline conditionals would be so messy, my first inclination was to restructure the project with separate sets of folders specific to each target, but that's a pretty major overhaul (especially considering git considers file-moves as delete/add changes that breaks change-history relationships). I'm still willing to tackle it, but it may actually be preferable (and certainly easier) to start a whole new .NET Core -friendly version and leave this one as a .NET Framework legacy project. Not to editorialize too much, but MS has clearly turned their backs on static-style libraries like Which way would you rather see this go? If you agree that a new project is appropriate, maybe you set up a new repo and structure, then I'll fork from there? |
@MV10 thanks for the details 👍 We've so far found it a pretty significant challenge to keep this sink functioning, since most of the Serilog contributors seem to use purpose-built log storage and not SQL Server. While I agree that a clean start would be nice, I am not sure about the chances of a second MSSQL sink getting enough maintenance attention to be viable, unless you're making long-term investments yourself in logging to SQL Server? I guess my initial thoughts tend towards preferring the refactoring, but only because of the maintenance problem. What do you think? |
@nblumhardt If you're more comfortable with refactoring (and ok losing the git history), I'll proceed with those changes. I just deleted a long reply -- my only real concern is that I think In terms of maintenance, there is a very good chance I'm aboard for the long-haul. Personally I have a startup effort that will generate lots of SQL logging, and I'm sold on Serilog to the point that anything else we start will use it. Plus my day job is Solution Architect for a very (very) large financial firm and I intend to try pushing our aging log4net infrastructure to Serilog. (I'm actually surprised the SQL sink isn't more popular with the enterprise... we have billions of rows logged in SQL via log4net today.) |
Awesome, sounds good @MV10 - will be fantastic having some help to get this sink into better shape! I agree with your assessment of I didn't mean to imply that the MSSQL sink is infrequently used - it's been downloaded a quarter of a million times - it's just that among the more active Serilog contributors, it's not been a frequent choice so far.
Yikes! :-) |
@nblumhardt The code is done (though I have more testing to do) in the sense that it compiles and the tests all pass, but there's a design issue I'm not comfortable about. I changed the Before I rolled up my sleeves to tackle testing, I decided to take a break and consider changes to the README file. The I realized there is a problem. Since a sink can only be configured once, by definition configuration-by-code and calling In the static But I suspect this will become a recurring theme as other sinks migrate to My first inclination is to suggest poor-man's DI by modifying I hope all that makes sense. I'm open to suggestions. |
My proposed fix above turns out to be slightly more complicated than I thought last night, but I think it will work. |
Is this pakage contains these changes ? Otherwise, please resend a new nuget package ? |
@jducobu I think it does. I don't have any control over the packaging but I think the dev packages are generated automatically. @nblumhardt Nick is that right? |
On my experience, only the main branch is packaged in alpha, beta version ... |
Hi- looks like the version info in the dev branch is incorrect - 5.1.2-dev-00201, released 21 days ago, should be a 5.1.3-* build. Fixing now 👍 |
Thanks @nblumhardt |
I have been developing an Azure Function on the V2 Functions library, the function uses our internal logging library (built off of serilog and this sink specifically). I've run into an issue where initializing the log causes a ConfigurationErrorsException to be thrown. I traced the exception down to this issue in the Azure Functions CLI Repo.
A comment on the Issue says "In 2.0, we have moved to the new ASP.NET Core configuration model. We intend to support binding to an IConfiguration instance that will provide a similar API, but in the meantime, the workaround is to read environment variables as opposed to relying on the ConfigurationManager and its APIs."
Looking through the source code I can see a few areas where the Configuration Manager is being used that would throw an exception during initialization they are as follows:
MSSqlServerConfigurationSection serviceConfigSection = ConfigurationManager.GetSection("MSSqlServerSettingsSection") as MSSqlServerConfigurationSection;
connectionString = GetConnectionString(connectionString);
var cs = ConfigurationManager.ConnectionStrings[nameOrConnectionString];
At present the library is un-usable in V2 functions.
The text was updated successfully, but these errors were encountered: