GithubHelp home page GithubHelp logo

akunzai / nhibernate.extensions.logging Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 306 KB

Use Microsoft.Extensions.Logging as NHibernate logging provider

License: MIT License

C# 100.00%
extension logging nhibernate

nhibernate.extensions.logging's People

Contributors

akunzai avatar dependabot[bot] avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

nhibernate.extensions.logging's Issues

NHibernate.Extensions.Logging causes NHibernate to work incorrectly

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.

Screenshots
image002

Additional context
Add any other context about the problem here.

ILoggerFactory extensions method is obsolete

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();

LoggerFactoryExtensions is ambiguous

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.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update dependency microsoft.extensions.logging.abstractions to v8

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.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
nuget
.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

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.