akunzai / nhibernate.extensions.logging Goto Github PK
View Code? Open in Web Editor NEWUse Microsoft.Extensions.Logging as NHibernate logging provider
License: MIT License
Use Microsoft.Extensions.Logging as NHibernate logging provider
License: MIT License
Describe the bug
I've recently upgraded my application from .NET 3.1 to 6.0. Version of NHibernate was not changed - it was 5.2.5.0.
I've change also logging method. Previously NHibernate was logging to Common.Logging via NHibernate.Logging. After upgrade I've installed and configured NHibernate.Extensions.Logging
Simple tests confirmed that change was successfully implemented.
However after some time we've found that queries contained join work incorrectly. For JoinEntityAlias method (as in screenshot) we've got incorrect syntax - part of where statement was put into the from clause. Message was "could not execute query".
I've converted JoinEntityAlias into proper Linq query. Then we've obtained message "undefined join type".
We have other types of specyfying joins but I haven't tested it.
After removing Nuget package with NEL everything was back to normal.
I've recompiled NEL from sources referencing our local copy of NHibernate.dll and then used this instead of oryginal NEL NuGet package. Everything behaves as expected.
To Reproduce
Steps to reproduce the behavior:
Install NHibernate version 5.2.5.0 . Create a query with JoinEntityAlias.
Then install NHibernate.Extensions.Logging version 2.3.1 Nuget.
Add
var loggerFactory = app.ApplicationServices.GetRequiredService<Microsoft.Extensions.Logging.ILoggerFactory>();
NHibernateLogger.SetLoggersFactory(new MicrosoftLoggerFactory(loggerFactory));
in Configure method in Startup class.
Query will not run as before.
Expected behavior
Logging should never change application behavior. Especially it should not change generated queries.
Additional context
Add any other context about the problem here.
since Microsoft.Extensions.Logging 2.2.0, following code will caused compiler warnings
var loggerFactory = new LoggerFactory()
.AddDebug()
.UseAsNHibernateLoggerProvider();
This method is obsolete and will be removed in a future version. The recommended alternative is AddDebug(this ILoggingBuilder builder).
instead of initiates LoggerFactory directly, your should inject it by DI containers
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
loggerFactory.UseAsNHibernateLoggerProvider();
This project's clone of Microsoft.Extensions.Logging.LoggerFactoryExtensions collides with the one from Microsoft's package. I have code that is reflectively looking up a method in Microsft's LoggerFactoryExtensions class, but the compiler complains:
[CS0433] The type 'LoggerFactoryExtensions' exists in both 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'NHibernate.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'
I don't think there's anything requiring your extension method class to have the same name, nor same namespace as Microsoft's. All that matters is that the type of the this parameter be Microsoft's LoggerFactory.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These branches will be created by Renovate only once you click their checkbox below.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
.github/workflows/cd.yml
actions/checkout v4
actions/setup-dotnet v3
.github/workflows/ci.yml
actions/checkout v4
actions/setup-dotnet v3
codecov/codecov-action v3
.config/dotnet-tools.json
dotnet-reportgenerator-globaltool 5.2.0
Directory.Packages.props
xunit 2.6.2
xunit.runner.visualstudio 2.5.4
System.Text.RegularExpressions 4.3.1
System.Net.Http 4.3.4
System.Data.SQLite.Core 1.0.118
System.Drawing.Common 8.0.0
NHibernate 5.4.7
Newtonsoft.Json 13.0.3
Moq 4.20.70
Microsoft.TestPlatform.ObjectModel 17.8.0
Microsoft.NETFramework.ReferenceAssemblies 1.0.3
Microsoft.NET.Test.Sdk 17.8.0
FluentNHibernate 3.3.0
coverlet.collector 6.0.0
Microsoft.Extensions.Logging.Abstractions 2.2.0
src/NHibernate.Extensions.Logging/NHibernate.Extensions.Logging.csproj
NHibernate 5.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.