Skip to content

ASP.NET Core: Cannot set "nhibernate-logger" in app.config. There is no app.config in .Net Core applications #1697

@karelkral

Description

@karelkral

There is "nhibernate-logger" setting, which is read from app.config or web.config.
But in .ASP.Net Core, app.config does not exist. There is appsettings.json only. Would it be possible to set nhibernate-logger from NHibernate.Cfg.Environment, from hibernate.cfg.xml or programmaticaly?

There is workaround how to copy settings from appsettings.json to ConfigurationManager, but this is not clean solution here

The code for reading nhibernate-logger is in NHibernateLogger

private static string GetNhibernateLoggerClass()
{
      var nhibernateLogger = ConfigurationManager.AppSettings.Keys.Cast<string>().FirstOrDefault(k => nhibernateLoggerConfKey.Equals(k, StringComparison.OrdinalIgnoreCase));
	string nhibernateLoggerClass = null;
	if (string.IsNullOrEmpty(nhibernateLogger))
	{
		// look for log4net.dll
               // other code...			
        }
	return nhibernateLoggerClass;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions