diff --git a/examples/Directory.Packages.props b/examples/Directory.Packages.props index 27d06de2..941a3a17 100644 --- a/examples/Directory.Packages.props +++ b/examples/Directory.Packages.props @@ -5,9 +5,9 @@ - - - + + + diff --git a/examples/Spring/Spring.Calculator/Spring.Calculator.sln b/examples/Spring/Spring.Calculator/Spring.Calculator.sln index eb3278af..ecd5a402 100644 --- a/examples/Spring/Spring.Calculator/Spring.Calculator.sln +++ b/examples/Spring/Spring.Calculator/Spring.Calculator.sln @@ -5,7 +5,6 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B1FF7E1F-9BF9-4EB3-B38C-39A0E3EA4D0A}" ProjectSection(SolutionItems) = preProject readme.txt = readme.txt - SpringCalculator.snk = SpringCalculator.snk EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Calculator.Services.2010", "src\Spring.Calculator.Services\Spring.Calculator.Services.csproj", "{D9FB04E5-D636-4EC2-A3AB-FAB1C4F37827}" diff --git a/examples/Spring/Spring.Calculator/src/Spring.Aspects/Logging/CommonLoggingAroundAdvice.cs b/examples/Spring/Spring.Calculator/src/Spring.Aspects/Logging/CommonLoggingAroundAdvice.cs index 35113d36..879976de 100644 --- a/examples/Spring/Spring.Calculator/src/Spring.Aspects/Logging/CommonLoggingAroundAdvice.cs +++ b/examples/Spring/Spring.Calculator/src/Spring.Aspects/Logging/CommonLoggingAroundAdvice.cs @@ -1,14 +1,14 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. - * + * Copyright � 2002-2011 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ using System; using AopAlliance.Intercept; -using Common.Logging; +using Microsoft.Extensions.Logging; #endregion @@ -37,13 +37,13 @@ namespace Spring.Aspects.Logging { #region Logging - private static readonly ILog LOG = LogManager.GetLogger(typeof(CommonLoggingAroundAdvice)); + private static readonly ILogger LOG = LogManager.GetLogger(typeof(CommonLoggingAroundAdvice)); #endregion #region Fields - private LogLevel _level = LogLevel.All; + private LogLevel _level = LogLevel.Trace; #endregion @@ -51,7 +51,7 @@ namespace Spring.Aspects.Logging public LogLevel Level { - get { return _level; } + get { return _level; } set { _level = value; } } @@ -75,23 +75,23 @@ namespace Spring.Aspects.Logging { switch(Level) { - case LogLevel.All : + case LogLevel.Trace : case LogLevel.Debug : - if (LOG.IsDebugEnabled) LOG.Debug(String.Format(text, args)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.LogDebug(String.Format(text, args)); break; case LogLevel.Error : - if (LOG.IsErrorEnabled) LOG.Error(String.Format(text, args)); + if (LOG.IsEnabled(LogLevel.Error)) LOG.LogError(String.Format(text, args)); break; - case LogLevel.Fatal : - if (LOG.IsFatalEnabled) LOG.Fatal(String.Format(text, args)); + case LogLevel.Critical : + if (LOG.IsEnabled(LogLevel.Critical)) LOG.LogCritical(String.Format(text, args)); break; - case LogLevel.Info : - if (LOG.IsInfoEnabled) LOG.Info(String.Format(text, args)); + case LogLevel.Information : + if (LOG.IsEnabled(LogLevel.Information)) LOG.LogInformation(String.Format(text, args)); break; - case LogLevel.Warn : - if (LOG.IsWarnEnabled) LOG.Warn(String.Format(text, args)); + case LogLevel.Warning: + if (LOG.IsEnabled(LogLevel.Warning)) LOG.LogWarning(String.Format(text, args)); break; - case LogLevel.Off: + case LogLevel.None: default : break; } @@ -99,4 +99,4 @@ namespace Spring.Aspects.Logging #endregion } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.Calculator/src/Spring.Aspects/Spring.Aspects.csproj b/examples/Spring/Spring.Calculator/src/Spring.Aspects/Spring.Aspects.csproj index b4c902aa..c8d94e47 100644 --- a/examples/Spring/Spring.Calculator/src/Spring.Aspects/Spring.Aspects.csproj +++ b/examples/Spring/Spring.Calculator/src/Spring.Aspects/Spring.Aspects.csproj @@ -11,6 +11,6 @@ - + \ No newline at end of file diff --git a/examples/Spring/Spring.Calculator/src/Spring.Calculator.Web/Spring.Calculator.Web.csproj b/examples/Spring/Spring.Calculator/src/Spring.Calculator.Web/Spring.Calculator.Web.csproj index 36d0f93c..6de6ef49 100644 --- a/examples/Spring/Spring.Calculator/src/Spring.Calculator.Web/Spring.Calculator.Web.csproj +++ b/examples/Spring/Spring.Calculator/src/Spring.Calculator.Web/Spring.Calculator.Web.csproj @@ -45,15 +45,6 @@ 4 - - ..\..\..\..\..\lib\Net\2.0\Common.Logging.dll - - - ..\..\..\..\..\lib\Net\2.0\Common.Logging.Log4Net1211.dll - - - ..\..\..\..\..\lib\Net\4.0\log4net.dll - ..\..\..\..\..\bin\net\4.0\debug\Spring.Aop.dll diff --git a/examples/Spring/Spring.CodeConfig.Migration/src/SpringApp/SpringApp.csproj b/examples/Spring/Spring.CodeConfig.Migration/src/SpringApp/SpringApp.csproj index 5dd27a45..a7b02272 100644 --- a/examples/Spring/Spring.CodeConfig.Migration/src/SpringApp/SpringApp.csproj +++ b/examples/Spring/Spring.CodeConfig.Migration/src/SpringApp/SpringApp.csproj @@ -7,7 +7,7 @@ - + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FedExShippingService.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FedExShippingService.cs index 2de081e1..656580a4 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FedExShippingService.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FedExShippingService.cs @@ -20,10 +20,7 @@ #region Imports -using System; - -using Common.Logging; - +using Microsoft.Extensions.Logging; using Spring.Northwind.Domain; #endregion @@ -32,11 +29,11 @@ namespace Spring.Northwind.Service { public class FedExShippingService : IShippingService { - protected static readonly ILog log = LogManager.GetLogger(typeof (FedExShippingService)); + protected static readonly ILogger log = LogManager.GetLogger(typeof (FedExShippingService)); public void ShipOrder(Order order) { log.Info("Shipping order id = " + order.Id); } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs index 64247d29..fd46b8e1 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs @@ -21,10 +21,8 @@ #region Imports using System; -using System.Collections; - -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Transaction.Interceptor; using Spring.Northwind.Dao; @@ -38,7 +36,7 @@ namespace Spring.Northwind.Service { #region Fields - private static readonly ILog log = LogManager.GetLogger(typeof (FulfillmentService)); + private static readonly ILogger log = LogManager.GetLogger(typeof (FulfillmentService)); private IProductDao productDao; diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/FulfillmentResult.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/FulfillmentResult.aspx.cs index 2066df8f..23d56d2b 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/FulfillmentResult.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/FulfillmentResult.aspx.cs @@ -1,15 +1,5 @@ using System; -using System.IO; - -using log4net.Appender; -using log4net.Core; -using log4net.Layout; -using log4net.Repository; - using Spring.Northwind.Service; -using Spring.Web.UI; - -using LogManager=log4net.LogManager; public partial class FullfillmentResult : ConversationPage { @@ -28,36 +18,8 @@ public partial class FullfillmentResult : ConversationPage protected void Page_Load(object sender, EventArgs e) { - // gather log4net output with small hack to get results... - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); - MemoryAppender appender = null; - foreach (IAppender a in appenders) - { - if (a is MemoryAppender) - { - // we found our appender to look results from - appender = a as MemoryAppender; - break; - } - } - - if (appender != null) - { - appender.Clear(); - fulfillmentService.ProcessCustomer(customerEditController.CurrentCustomer.Id); - LoggingEvent[] events = appender.GetEvents(); - StringWriter stringWriter = new StringWriter(); - PatternLayout layout = new PatternLayout("%date{HH:mm:ss} %-5level %logger{1}: %message
"); - foreach (LoggingEvent loggingEvent in events) - { - layout.Format(stringWriter, loggingEvent); - } - - results.Text = stringWriter.ToString(); - } - } + protected void customerOrders_Click(object sender, EventArgs e) { SetResult("Back"); diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/Spring.Northwind.Web.Conversation.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/Spring.Northwind.Web.Conversation.csproj index f144108f..19444d64 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/Spring.Northwind.Web.Conversation.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/Spring.Northwind.Web.Conversation.csproj @@ -42,7 +42,7 @@ 4 - + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/FulfillmentResult.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/FulfillmentResult.aspx.cs index 9b4871f8..56e9444c 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/FulfillmentResult.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/FulfillmentResult.aspx.cs @@ -1,16 +1,8 @@ using System; -using System.IO; - -using log4net.Appender; -using log4net.Core; -using log4net.Layout; -using log4net.Repository; using Spring.Northwind.Service; using Spring.Web.UI; -using LogManager=log4net.LogManager; - public partial class FullfillmentResult : Page { private IFulfillmentService fulfillmentService; @@ -28,36 +20,8 @@ public partial class FullfillmentResult : Page protected void Page_Load(object sender, EventArgs e) { - // gather log4net output with small hack to get results... - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); - MemoryAppender appender = null; - foreach (IAppender a in appenders) - { - if (a is MemoryAppender) - { - // we found our appender to look results from - appender = a as MemoryAppender; - break; - } - } - - if (appender != null) - { - appender.Clear(); - fulfillmentService.ProcessCustomer(customerEditController.CurrentCustomer.Id); - LoggingEvent[] events = appender.GetEvents(); - StringWriter stringWriter = new StringWriter(); - PatternLayout layout = new PatternLayout("%date{HH:mm:ss} %-5level %logger{1}: %message
"); - foreach (LoggingEvent loggingEvent in events) - { - layout.Format(stringWriter, loggingEvent); - } - - results.Text = stringWriter.ToString(); - } - } + protected void customerOrders_Click(object sender, EventArgs e) { SetResult("Back"); diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Spring.Northwind.Web.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Spring.Northwind.Web.csproj index 9f06aae7..4eff6ab5 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Spring.Northwind.Web.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Spring.Northwind.Web.csproj @@ -42,7 +42,7 @@ 4 - + diff --git a/examples/Spring/Spring.DataQuickStart/src/Spring/Spring.DataQuickStart/Spring.DataQuickStart.csproj b/examples/Spring/Spring.DataQuickStart/src/Spring/Spring.DataQuickStart/Spring.DataQuickStart.csproj index 7571da76..b86642b0 100644 --- a/examples/Spring/Spring.DataQuickStart/src/Spring/Spring.DataQuickStart/Spring.DataQuickStart.csproj +++ b/examples/Spring/Spring.DataQuickStart/src/Spring/Spring.DataQuickStart/Spring.DataQuickStart.csproj @@ -4,7 +4,7 @@ Spring - + diff --git a/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/App.config b/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/App.config index ede163f1..bf12c959 100644 --- a/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/App.config +++ b/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/App.config @@ -2,9 +2,6 @@ - -
-
@@ -12,17 +9,6 @@
- - - - - - - - - - - diff --git a/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/MovieFinder/Program.cs b/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/MovieFinder/Program.cs index d59bd7b0..b5b9239c 100644 --- a/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/MovieFinder/Program.cs +++ b/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/MovieFinder/Program.cs @@ -21,8 +21,7 @@ #region Imports using System; -using Common.Logging; -using Common.Logging.Log4Net; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; using Spring.Objects.Factory.Config; @@ -46,7 +45,7 @@ namespace Spring.IocQuickStart.MovieFinder { #region Logging Definition - private static readonly ILog LOG = LogManager.GetLogger(typeof(Program)); + private static readonly ILogger LOG = LogManager.GetLogger(typeof(Program)); #endregion @@ -94,7 +93,7 @@ namespace Spring.IocQuickStart.MovieFinder private static IApplicationContext CreateContextProgrammatically() { - InitializeCommonLogging(); + InitializeLogging(); GenericApplicationContext ctx = new GenericApplicationContext(); IObjectDefinitionFactory objectDefinitionFactory = new DefaultObjectDefinitionFactory(); @@ -119,7 +118,7 @@ namespace Spring.IocQuickStart.MovieFinder private static IApplicationContext CreateContextProgrammaticallyWithAutoWire() { - InitializeCommonLogging(); + InitializeLogging(); GenericApplicationContext ctx = new GenericApplicationContext(); IObjectDefinitionFactory objectDefinitionFactory = new DefaultObjectDefinitionFactory(); @@ -165,14 +164,15 @@ namespace Spring.IocQuickStart.MovieFinder return ctx; } - private static void InitializeCommonLogging() + private static void InitializeLogging() { - var properties = new Common.Logging.Configuration.NameValueCollection(); - properties["configType"] = "INLINE"; - LogManager.Adapter = new Log4NetLoggerFactoryAdapter(properties); + var loggerFactory = LoggerFactory.Create( + builder => builder.AddLog4Net()); + + LogManager.LoggerFactory = loggerFactory; } #endregion } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/Spring.IocQuickStart.MovieFinder.csproj b/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/Spring.IocQuickStart.MovieFinder.csproj index 559f51fd..687f9d77 100644 --- a/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/Spring.IocQuickStart.MovieFinder.csproj +++ b/examples/Spring/Spring.IoCQuickStart.MovieFinder/src/Spring.IocQuickStart.MovieFinder.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/App.config b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/App.config index c1474dd5..d5aeb1ce 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/App.config +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/App.config @@ -7,10 +7,6 @@
- -
- - diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Handlers/StockAppHandler.cs b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Handlers/StockAppHandler.cs index d758d33d..a2fd77cc 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Handlers/StockAppHandler.cs +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Handlers/StockAppHandler.cs @@ -1,7 +1,4 @@ - - -using System.Collections; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.MsmqQuickStart.Client.UI; using Spring.MsmqQuickStart.Common.Data; @@ -11,7 +8,7 @@ namespace Spring.MsmqQuickStart.Client.Handlers { #region Logging Definition - private readonly ILog log = LogManager.GetLogger(typeof(StockAppHandler)); + private readonly ILogger log = LogManager.GetLogger(typeof(StockAppHandler)); #endregion @@ -45,4 +42,4 @@ namespace Spring.MsmqQuickStart.Client.Handlers log.Error("could not handle object of type = " + catchAllObject.GetType()); } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Program.cs b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Program.cs index 902503c2..a0da755b 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Program.cs +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Program.cs @@ -1,7 +1,7 @@ using System; using System.Threading; using System.Windows.Forms; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; using Spring.MsmqQuickStart.Client.UI; @@ -12,7 +12,7 @@ namespace Spring.MsmqQuickStart.Client static class Program { - private static readonly ILog log = LogManager.GetLogger(typeof(Program)); + private static readonly ILogger log = LogManager.GetLogger(typeof(Program)); /// /// The main entry point for the application. @@ -44,4 +44,4 @@ namespace Spring.MsmqQuickStart.Client Application.Exit(); } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Spring.MsmqQuickStart.Client.csproj b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Spring.MsmqQuickStart.Client.csproj index a691c168..9b439de0 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Spring.MsmqQuickStart.Client.csproj +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/Spring.MsmqQuickStart.Client.csproj @@ -41,6 +41,6 @@ - + \ No newline at end of file diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/UI/StockForm.cs b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/UI/StockForm.cs index 5e151616..1bd63c98 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/UI/StockForm.cs +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Client/UI/StockForm.cs @@ -1,7 +1,6 @@ using System; -using System.Collections; using System.Windows.Forms; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Context.Support; using Spring.MsmqQuickStart.Common.Data; @@ -11,7 +10,7 @@ namespace Spring.MsmqQuickStart.Client.UI { #region Logging Definition - private static readonly ILog log = LogManager.GetLogger(typeof (StockForm)); + private static readonly ILogger log = LogManager.GetLogger(typeof (StockForm)); #endregion @@ -58,4 +57,4 @@ namespace Spring.MsmqQuickStart.Client.UI } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/App.config b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/App.config index 2f89a5f0..d49439c2 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/App.config +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/App.config @@ -7,10 +7,6 @@
- -
- - diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Gateways/MarketDataServiceGateway.cs b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Gateways/MarketDataServiceGateway.cs index a32633aa..38be70d5 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Gateways/MarketDataServiceGateway.cs +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Gateways/MarketDataServiceGateway.cs @@ -1,7 +1,6 @@ using System; -using System.Collections; using System.Threading; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Messaging.Core; @@ -9,7 +8,7 @@ namespace Spring.MsmqQuickStart.Server.Gateways { public class MarketDataServiceGateway : MessageQueueGatewaySupport, IMarketDataService { - private static readonly ILog log = LogManager.GetLogger(typeof (MarketDataServiceGateway)); + private static readonly ILogger log = LogManager.GetLogger(typeof (MarketDataServiceGateway)); private readonly Random random; private TimeSpan sleepTimeInSeconds = new TimeSpan(0,0,0,10,0); diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Handlers/StockAppHandler.cs b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Handlers/StockAppHandler.cs index 383b0ec6..5cbfaebc 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Handlers/StockAppHandler.cs +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Handlers/StockAppHandler.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Threading; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.MsmqQuickStart.Common.Data; using Spring.MsmqQuickStart.Server.Services; using Spring.Util; @@ -11,7 +11,7 @@ namespace Spring.MsmqQuickStart.Server.Handlers { public class StockAppHandler { - private readonly ILog log = LogManager.GetLogger(typeof(StockAppHandler)); + private readonly ILogger log = LogManager.GetLogger(typeof(StockAppHandler)); private readonly IExecutionVenueService executionVenueService; private readonly ICreditCheckService creditCheckService; @@ -46,4 +46,4 @@ namespace Spring.MsmqQuickStart.Server.Handlers return tradeResponse; } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Spring.MsmqQuickStart.Server.csproj b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Spring.MsmqQuickStart.Server.csproj index ed10683e..ae5e9b9a 100644 --- a/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Spring.MsmqQuickStart.Server.csproj +++ b/examples/Spring/Spring.MsmqQuickStart/src/Spring/Spring.MsmqQuickStart.Server/Spring.MsmqQuickStart.Server.csproj @@ -20,6 +20,6 @@ - + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs index d6c44096..e5a01ef8 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs @@ -1,25 +1,25 @@ #region License -/* - * Copyright 2002-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion using System.Collections; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.NmsQuickStart.Client.UI; using Spring.NmsQuickStart.Common.Data; @@ -29,7 +29,7 @@ namespace Spring.NmsQuickStart.Client.Handlers { #region Logging Definition - private readonly ILog log = LogManager.GetLogger(typeof(StockAppHandler)); + private readonly ILogger log = LogManager.GetLogger(typeof(StockAppHandler)); #endregion @@ -63,4 +63,4 @@ namespace Spring.NmsQuickStart.Client.Handlers log.Error("could not handle object of type = " + catchAllObject.GetType()); } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs index 9898a0c7..ccb1b39d 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs @@ -1,19 +1,19 @@ #region License -/* - * Copyright 2002-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion @@ -21,7 +21,7 @@ using System; using System.Threading; using System.Windows.Forms; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; using Spring.NmsQuickStart.Client.UI; @@ -31,7 +31,7 @@ namespace Spring.NmsQuickStart.Client static class Program { - private static readonly ILog log = LogManager.GetLogger(typeof(Program)); + private static readonly ILogger log = LogManager.GetLogger(typeof(Program)); /// /// The main entry point for the application. @@ -41,7 +41,7 @@ namespace Spring.NmsQuickStart.Client { try { - log.Info("Running...."); + log.LogInformation("Running...."); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (IApplicationContext ctx = ContextRegistry.GetContext()) @@ -53,14 +53,14 @@ namespace Spring.NmsQuickStart.Client } catch (Exception e) { - log.Error("Spring.NmsQuickStart.Client is broken.", e); + log.LogError("Spring.NmsQuickStart.Client is broken.", e); } } private static void ThreadException(object sender, ThreadExceptionEventArgs e) { - log.Error("Uncaught application exception.", e.Exception); + log.LogError(e.Exception, "Uncaught application exception."); Application.Exit(); } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj index d7446a41..86b619a3 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj @@ -7,7 +7,7 @@ - + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs index e5585521..c408c87d 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs @@ -1,19 +1,19 @@ #region License -/* - * Copyright 2002-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion @@ -21,7 +21,7 @@ using System; using System.Collections; using System.Windows.Forms; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Context.Support; using Spring.NmsQuickStart.Common.Data; @@ -31,7 +31,7 @@ namespace Spring.NmsQuickStart.Client.UI { #region Logging Definition - private static readonly ILog log = LogManager.GetLogger(typeof (StockForm)); + private static readonly ILogger log = LogManager.GetLogger(typeof (StockForm)); #endregion @@ -83,4 +83,4 @@ namespace Spring.NmsQuickStart.Client.UI } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataServiceGateway.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataServiceGateway.cs index b4785e73..3cf5299f 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataServiceGateway.cs +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataServiceGateway.cs @@ -1,14 +1,14 @@ using System; using System.Collections; using System.Threading; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Messaging.Nms.Core; namespace Spring.NmsQuickStart.Server.Gateways { public class MarketDataServiceGateway : NmsGatewaySupport, IMarketDataService { - private static readonly ILog log = LogManager.GetLogger(typeof (MarketDataServiceGateway)); + private static readonly ILogger log = LogManager.GetLogger(typeof (MarketDataServiceGateway)); private readonly Random random; private TimeSpan sleepTimeInSeconds = new TimeSpan(0,0,0,10,0); @@ -62,4 +62,4 @@ namespace Spring.NmsQuickStart.Server.Gateways //y2 = x2 * w; } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/LoggingExceptionListener.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/LoggingExceptionListener.cs index e9e11d90..e27495b1 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/LoggingExceptionListener.cs +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/LoggingExceptionListener.cs @@ -1,7 +1,7 @@ using System; -using Common.Logging; +using Microsoft.Extensions.Logging; using Spring.Messaging.Nms.Core; namespace Spring.NmsQuickStart.Server.Handlers @@ -10,7 +10,7 @@ namespace Spring.NmsQuickStart.Server.Handlers { #region Logging - private readonly ILog logger = LogManager.GetLogger(typeof(LoggingExceptionListener)); + private readonly ILogger logger = LogManager.GetLogger(typeof(LoggingExceptionListener)); #endregion @@ -20,7 +20,7 @@ namespace Spring.NmsQuickStart.Server.Handlers /// The exception. public void OnException(Exception exception) { - logger.Info("********* Caught exception *************", exception); + logger.LogInformation(exception, "********* Caught exception *************"); } } -} \ No newline at end of file +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj index 254bb786..6dfc3db7 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Spring/Spring.Scheduling.Quartz.Example/src/Spring.Scheduling.Quartz.Example.csproj b/examples/Spring/Spring.Scheduling.Quartz.Example/src/Spring.Scheduling.Quartz.Example.csproj index 0f1fdae8..0fdafa9a 100644 --- a/examples/Spring/Spring.Scheduling.Quartz.Example/src/Spring.Scheduling.Quartz.Example.csproj +++ b/examples/Spring/Spring.Scheduling.Quartz.Example/src/Spring.Scheduling.Quartz.Example.csproj @@ -6,9 +6,6 @@ - - - diff --git a/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/Spring.TxQuickStart.Tests.csproj b/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/Spring.TxQuickStart.Tests.csproj index 5015c0dd..18870d47 100644 --- a/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/Spring.TxQuickStart.Tests.csproj +++ b/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/Spring.TxQuickStart.Tests.csproj @@ -22,7 +22,6 @@ - diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 36d33bc1..79a40d16 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -48,9 +48,7 @@ - - - + diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 3f24a9a6..99e320a0 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -13,6 +13,7 @@ + diff --git a/src/Spring/Spring.Aop/Aop/Framework/Adapter/ThrowsAdviceInterceptor.cs b/src/Spring/Spring.Aop/Aop/Framework/Adapter/ThrowsAdviceInterceptor.cs index 6c94c469..4d2b1be6 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/Adapter/ThrowsAdviceInterceptor.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/Adapter/ThrowsAdviceInterceptor.cs @@ -23,6 +23,7 @@ using System.Collections; using System.Reflection; using AopAlliance.Intercept; +using Microsoft.Extensions.Logging; using Spring.Util; #endregion @@ -162,7 +163,7 @@ namespace Spring.Aop.Framework.Adapter { #region Instrumentation - if(log.IsDebugEnabled) + if(log.IsEnabled(LogLevel.Debug)) { log.Debug("Found exception handler method: " + method); } @@ -263,7 +264,7 @@ namespace Spring.Aop.Framework.Adapter #region Instrumentation - if(log.IsDebugEnabled) + if(log.IsEnabled(LogLevel.Debug)) { log.Debug("Trying to find handler for exception of type [" + exception.GetType().Name + "]."); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs index e15dcad2..42c39213 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; @@ -182,7 +183,7 @@ namespace Spring.Aop.Framework.AutoProxy { if (candidate is IIntroductionAdvisor && AopUtils.CanApply(candidate, targetType, null)) { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]"); } @@ -197,7 +198,7 @@ namespace Spring.Aop.Framework.AutoProxy if (AopUtils.CanApply(candidate, targetType, null, hasIntroductions)) { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]"); } @@ -205,7 +206,7 @@ namespace Spring.Aop.Framework.AutoProxy } else { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info($"Candidate advisor [{candidate}] rejected for targetType [{targetType}]"); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs index 3b86aea6..c249ce09 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Reflection; using AopAlliance.Aop; +using Microsoft.Extensions.Logging; using Spring.Aop.Framework.Adapter; using Spring.Aop.Target; using Spring.Collections; @@ -235,7 +236,7 @@ namespace Spring.Aop.Framework.AutoProxy if (IsInfrastructureType(objectType, objectName)) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType)); } @@ -246,7 +247,7 @@ namespace Spring.Aop.Framework.AutoProxy if (ShouldSkip(objectType, objectName)) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Skipping type [{0}]", objectType)); } @@ -387,7 +388,7 @@ namespace Spring.Aop.Framework.AutoProxy if (ts != null) { // found a match - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info(string.Format("TargetSourceCreator [{0} found custom TargetSource for object with objectName '{1}'", tsc, name)); } @@ -509,7 +510,7 @@ namespace Spring.Aop.Framework.AutoProxy } } } - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Count : 0; int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Count : 0; @@ -573,7 +574,7 @@ namespace Spring.Aop.Framework.AutoProxy if (IsInfrastructureType(objectType, objectName)) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType)); } @@ -584,7 +585,7 @@ namespace Spring.Aop.Framework.AutoProxy if (ShouldSkip(objectType, objectName)) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Skipping type [{0}]", objectType)); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs index 6bbf8154..0c8792c6 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; using Spring.Util; @@ -87,7 +88,7 @@ namespace Spring.Aop.Framework.AutoProxy ObjectCurrentlyInCreationException oce = (ObjectCurrentlyInCreationException)rootEx; if (_objectFactory.IsCurrentlyInCreation(oce.ObjectName)) { - if (_log.IsDebugEnabled) + if (_log.IsEnabled(LogLevel.Debug)) { _log.Debug(string.Format("Ignoring currently created advisor '{0}': exception message = {1}", name, ex.Message)); diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target/AbstractPrototypeTargetSourceCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target/AbstractPrototypeTargetSourceCreator.cs index 7050af43..06e0fdb7 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target/AbstractPrototypeTargetSourceCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target/AbstractPrototypeTargetSourceCreator.cs @@ -20,6 +20,7 @@ #region Imports +using Microsoft.Extensions.Logging; using Spring.Aop.Target; using Spring.Objects.Factory; using Spring.Objects.Factory.Support; @@ -61,14 +62,14 @@ namespace Spring.Aop.Framework.AutoProxy.Target { if (!(factory is IObjectDefinitionRegistry)) { - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) logger.Warn("Cannot do autopooling with a IObjectFactory that doesn't implement IObjectDefinitionRegistry"); return null; } IObjectDefinitionRegistry definitionRegistry = (IObjectDefinitionRegistry) factory; RootObjectDefinition definition = (RootObjectDefinition) definitionRegistry.GetObjectDefinition(name); - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) logger.Info("Configuring AbstractPrototypeBasedTargetSource..."); // Infinite cycle will result if we don't use a different factory, diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs index 8b208aea..8793a93d 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs @@ -22,6 +22,7 @@ using System.Text; using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Proxy; #endregion @@ -48,7 +49,7 @@ namespace Spring.Aop.Framework.DynamicProxy public class CachedAopProxyFactory : DefaultAopProxyFactory { /// - /// The shared instance for this class. + /// The shared instance for this class. /// private static readonly ILog logger = LogManager.GetLogger(typeof(CachedAopProxyFactory)); @@ -101,9 +102,9 @@ namespace Spring.Aop.Framework.DynamicProxy { #region Instrumentation - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { - logger.DebugFormat("AOP proxy type found in cache for '{0}'.", cacheKey); + logger.LogDebug("AOP proxy type found in cache for {CacheKey}", cacheKey); } #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs b/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs index 4866fe29..e18a803a 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs @@ -18,6 +18,7 @@ using System.Runtime.Serialization; using AopAlliance.Aop; using AopAlliance.Intercept; +using Microsoft.Extensions.Logging; using Spring.Aop.Framework.Adapter; using Spring.Aop.Support; using Spring.Aop.Target; @@ -86,7 +87,7 @@ namespace Spring.Aop.Framework : AdvisedSupport, IFactoryObject, IObjectFactoryAware { /// - /// The instance for this class. + /// The instance for this class. /// private static readonly ILog logger = LogManager.GetLogger(); @@ -439,7 +440,7 @@ namespace Spring.Aop.Framework // in the case of a prototype, we need to give the proxy // an independent instance of the configuration... - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Creating copy of prototype ProxyFactoryObject config: " + this); } @@ -451,7 +452,7 @@ namespace Spring.Aop.Framework AdvisedSupport copy = new AdvisedSupport(); copy.CopyConfigurationFrom(this, targetSource, advisorChain, introductionChain); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Using ProxyConfig: " + copy); } @@ -466,7 +467,7 @@ namespace Spring.Aop.Framework /// private void Initialize() { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Initialize: begin configure target, interceptors and introductions for {0}[{1}]", GetType().Name, GetHashCode())); } @@ -474,7 +475,7 @@ namespace Spring.Aop.Framework InitializeAdvisorChain(); InitializeIntroductionChain(); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Initialize: completed configuration for {0}[{1}]: {2}", GetType().Name, GetHashCode(), ToProxyConfigString())); } @@ -520,7 +521,7 @@ namespace Spring.Aop.Framework throw new AopConfigException("Can only use global advisors or interceptors in conjunction with an IListableObjectFactory."); } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Adding global advisor '" + name + "'"); } @@ -529,7 +530,7 @@ namespace Spring.Aop.Framework } else { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("resolving advisor name " + "'" + name + "'"); } @@ -555,7 +556,7 @@ namespace Spring.Aop.Framework { if (advice is IAdvisors) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Adding advisor list '{0}'", name)); } @@ -563,7 +564,7 @@ namespace Spring.Aop.Framework IAdvisors advisors = (IAdvisors)advice; foreach (object element in advisors.Advisors) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, element.GetType().FullName)); } @@ -574,7 +575,7 @@ namespace Spring.Aop.Framework } else { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, advice.GetType().FullName)); } @@ -676,7 +677,7 @@ namespace Spring.Aop.Framework throw new AopConfigException("Found null interceptor name value in the InterceptorNames list; check your configuration."); } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Adding introduction '" + name + "'"); } @@ -794,7 +795,7 @@ namespace Spring.Aop.Framework { if (StringUtils.IsNullOrEmpty(targetName)) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Not Refreshing TargetSource: No target name specified"); } @@ -804,7 +805,7 @@ namespace Spring.Aop.Framework AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory"); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Refreshing TargetSource with name '" + targetName + "'"); } @@ -827,7 +828,7 @@ namespace Spring.Aop.Framework if (advisor is PrototypePlaceholder) { PrototypePlaceholder pa = (PrototypePlaceholder)advisor; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Refreshing advisor '{0}'", pa.ObjectName)); } @@ -859,7 +860,7 @@ namespace Spring.Aop.Framework if (introduction is PrototypePlaceholder) { PrototypePlaceholder pa = (PrototypePlaceholder)introduction; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Refreshing introduction '{0}'", pa.ObjectName)); } @@ -964,7 +965,7 @@ namespace Spring.Aop.Framework { // The target isn't an interceptor. targetName = finalName; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format("Object with name '{0}' concluding interceptor chain is not an advisor class: treating it as a target or TargetSource", finalName)); } diff --git a/src/Spring/Spring.Aop/Aop/Support/SdkRegularExpressionMethodPointcut.cs b/src/Spring/Spring.Aop/Aop/Support/SdkRegularExpressionMethodPointcut.cs index 5f1ba9d5..330d424f 100644 --- a/src/Spring/Spring.Aop/Aop/Support/SdkRegularExpressionMethodPointcut.cs +++ b/src/Spring/Spring.Aop/Aop/Support/SdkRegularExpressionMethodPointcut.cs @@ -16,6 +16,7 @@ using System.Runtime.Serialization; using System.Text.RegularExpressions; +using Microsoft.Extensions.Logging; using Spring.Util; namespace Spring.Aop.Support @@ -157,7 +158,7 @@ namespace Spring.Aop.Support Match match = _compiledPatterns[patternIndex].Match(pattern); bool matched = match.Success; - if (_logger.IsDebugEnabled) + if (_logger.IsEnabled(LogLevel.Debug)) { _logger.Debug("Candidate is: '" + pattern + "'; pattern is '" + _compiledPatterns[patternIndex].ToString() + "'; matched=" + matched); diff --git a/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs b/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs index 99005d35..f1990d53 100644 --- a/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs +++ b/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs @@ -20,6 +20,7 @@ #region Imports +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Util; @@ -135,7 +136,7 @@ namespace Spring.Aop.Target #region Instrumentation - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format( "Getting object with name '{0}' to determine class.", @@ -159,7 +160,7 @@ namespace Spring.Aop.Target { #region Instrumentation - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format( "Creating new target from object '{0}'.", @@ -237,7 +238,7 @@ namespace Spring.Aop.Target } /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected readonly ILog logger = LogManager.GetLogger(typeof (AbstractPrototypeTargetSource)); diff --git a/src/Spring/Spring.Aop/Aop/Target/SimplePoolTargetSource.cs b/src/Spring/Spring.Aop/Aop/Target/SimplePoolTargetSource.cs index 4b0a8eea..eda8f03d 100644 --- a/src/Spring/Spring.Aop/Aop/Target/SimplePoolTargetSource.cs +++ b/src/Spring/Spring.Aop/Aop/Target/SimplePoolTargetSource.cs @@ -20,6 +20,7 @@ #region Imports +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Pool; using Spring.Pool.Support; @@ -66,7 +67,7 @@ namespace Spring.Aop.Target { #region Instrumentation - if(logger.IsDebugEnabled) + if(logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Creating object pool."); } @@ -135,7 +136,7 @@ namespace Spring.Aop.Target { #region Instrumentation - if(logger.IsDebugEnabled) + if(logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Closing pool..."); } diff --git a/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs b/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs index 4ee1d7fe..0c061b35 100644 --- a/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs +++ b/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs @@ -21,7 +21,7 @@ #region Imports using AopAlliance.Intercept; - +using Microsoft.Extensions.Logging; using Spring.Aop.Support; using Spring.Collections; using Spring.Util; @@ -146,7 +146,7 @@ namespace Spring.Aop.Target { #region Instrumentation - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format( "No target for apartment prototype '{0}' " + @@ -185,7 +185,7 @@ namespace Spring.Aop.Target { #region Instrumentation - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Destroying ThreadLocal bindings"); } @@ -204,7 +204,7 @@ namespace Spring.Aop.Target { #region Instrumentation - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn(string.Format( "Thread-bound target of class '{0}' " + diff --git a/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs index 1ef825eb..fc621e6e 100644 --- a/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs @@ -21,6 +21,8 @@ #region Imports using System.Reflection; + + using Spring.Caching; using Spring.Context; using Spring.Expressions; diff --git a/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs index d7b8b932..9c5c1d88 100644 --- a/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs @@ -22,7 +22,7 @@ using System.Collections; using System.Reflection; - +using Microsoft.Extensions.Logging; using Spring.Aop; using Spring.Caching; using Spring.Util; @@ -114,7 +114,7 @@ namespace Spring.Aspects.Cache public void AfterReturning(object returnValue, MethodInfo method, object[] arguments, object target) { #region Instrumentation - bool isLogDebugEnabled = logger.IsDebugEnabled; + bool isLogDebugEnabled = logger.IsEnabled(LogLevel.Debug); #endregion CacheParameterInfo cpi = GetCacheParameterInfo(method); diff --git a/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs index 2f1c3085..0990bd54 100644 --- a/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs @@ -28,6 +28,7 @@ using AopAlliance.Intercept; using Spring.Caching; using Spring.Util; using System.Collections.Concurrent; +using Microsoft.Extensions.Logging; #endregion @@ -174,7 +175,7 @@ namespace Spring.Aspects.Cache if (resultInfo != null) { #region Instrumentation - bool isLogDebugEnabled = logger.IsDebugEnabled; + bool isLogDebugEnabled = logger.IsEnabled(LogLevel.Debug); #endregion AssertUtils.ArgumentNotNull(resultInfo.KeyExpression, "Key", @@ -266,7 +267,7 @@ namespace Spring.Aspects.Cache ICache cache = GetCache(itemInfo.CacheName); #region Instrumentation - bool isDebugEnabled = logger.IsDebugEnabled; + bool isDebugEnabled = logger.IsEnabled(LogLevel.Debug); #endregion foreach (object item in items) { diff --git a/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs index 55837094..cb43374b 100644 --- a/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs @@ -22,7 +22,7 @@ using System.Collections; using System.Reflection; - +using Microsoft.Extensions.Logging; using Spring.Aop; using Spring.Caching; @@ -95,7 +95,7 @@ namespace Spring.Aspects.Cache public void AfterReturning(object returnValue, MethodInfo method, object[] arguments, object target) { #region Instrumentation - bool isLogDebugEnabled = logger.IsDebugEnabled; + bool isLogDebugEnabled = logger.IsEnabled(LogLevel.Debug); #endregion InvalidateCacheAttribute[] cacheInfoArray = GetInvalidateCacheInfo(method); diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs index 436f07a2..f4794fab 100644 --- a/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs @@ -22,6 +22,8 @@ using System.Collections; using System.Reflection; using AopAlliance.Intercept; + + using Spring.Util; namespace Spring.Aspects.Exceptions diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs index 0b040087..4889058a 100644 --- a/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs +++ b/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Expressions; namespace Spring.Aspects.Exceptions diff --git a/src/Spring/Spring.Aop/Aspects/Logging/AbstractLoggingAdvice.cs b/src/Spring/Spring.Aop/Aspects/Logging/AbstractLoggingAdvice.cs index 672aff1f..f6706dba 100644 --- a/src/Spring/Spring.Aop/Aspects/Logging/AbstractLoggingAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Logging/AbstractLoggingAdvice.cs @@ -21,6 +21,7 @@ using System.Reflection; using System.Runtime.Serialization; using AopAlliance.Intercept; +using Microsoft.Extensions.Logging; using Spring.Aop.Framework; namespace Spring.Aspects.Logging @@ -204,7 +205,7 @@ namespace Spring.Aspects.Logging /// protected virtual bool IsLogEnabled(ILog log) { - return log.IsTraceEnabled; + return log.IsEnabled(LogLevel.Trace); } /// diff --git a/src/Spring/Spring.Aop/Aspects/Logging/SimpleLoggingAdvice.cs b/src/Spring/Spring.Aop/Aspects/Logging/SimpleLoggingAdvice.cs index ad4bf98c..1d80c28a 100644 --- a/src/Spring/Spring.Aop/Aspects/Logging/SimpleLoggingAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/Logging/SimpleLoggingAdvice.cs @@ -21,6 +21,7 @@ using System.Reflection; using System.Text; using AopAlliance.Intercept; +using Microsoft.Extensions.Logging; namespace Spring.Aspects.Logging { @@ -237,44 +238,43 @@ namespace Spring.Aspects.Logging { switch (LogLevel) { - case LogLevel.All: case LogLevel.Trace: - if (log.IsTraceEnabled) + if (log.IsEnabled(LogLevel.Trace)) { return true; } break; case LogLevel.Debug: - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { return true; } break; case LogLevel.Error: - if (log.IsErrorEnabled) + if (log.IsEnabled(LogLevel.Error)) { return true; } break; - case LogLevel.Fatal: - if (log.IsFatalEnabled) + case LogLevel.Critical: + if (log.IsEnabled(LogLevel.Critical)) { return true; } break; - case LogLevel.Info: - if (log.IsInfoEnabled) + case LogLevel.Information: + if (log.IsEnabled(LogLevel.Information)) { return true; } break; - case LogLevel.Warn: - if (log.IsWarnEnabled) + case LogLevel.Warning: + if (log.IsEnabled(LogLevel.Warning)) { return true; } break; - case LogLevel.Off: + case LogLevel.None: default: break; } @@ -417,44 +417,43 @@ namespace Spring.Aspects.Logging { switch (logLevel) { - case LogLevel.All: case LogLevel.Trace: - if (log.IsTraceEnabled) + if (log.IsEnabled(LogLevel.Trace)) { - if (e == null) log.Trace(text); else log.Trace(text, e); + if (e == null) log.Trace(text); else log.LogTrace(e, text); } break; case LogLevel.Debug: - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { if (e == null) log.Debug(text); else log.Debug(text, e); } break; case LogLevel.Error: - if (log.IsErrorEnabled) + if (log.IsEnabled(LogLevel.Error)) { if (e == null) log.Error(text); else log.Error(text, e); } break; - case LogLevel.Fatal: - if (log.IsFatalEnabled) + case LogLevel.Critical: + if (log.IsEnabled(LogLevel.Critical)) { - if (e == null) log.Fatal(text); else log.Fatal(text, e); + if (e == null) log.LogCritical(text); else log.LogCritical(e, text); } break; - case LogLevel.Info: - if (log.IsInfoEnabled) + case LogLevel.Information: + if (log.IsEnabled(LogLevel.Information)) { - if (e == null) log.Info(text); else log.Info(text, e); + if (e == null) log.Info(text); else log.LogInformation(e, text); } break; - case LogLevel.Warn: - if (log.IsWarnEnabled) + case LogLevel.Warning: + if (log.IsEnabled(LogLevel.Warning)) { - if (e == null) log.Warn(text); else log.Warn(text, e); + if (e == null) log.Warn(text); else log.LogWarning(e, text); } break; - case LogLevel.Off: + case LogLevel.None: default: break; } diff --git a/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs b/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs index 6ffaa647..b536f15f 100644 --- a/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs +++ b/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs @@ -20,6 +20,7 @@ using System.Text.RegularExpressions; using AopAlliance.Intercept; +using Microsoft.Extensions.Logging; using Spring.Core.TypeConversion; using Spring.Expressions; @@ -172,7 +173,7 @@ namespace Spring.Aspects } else { - if (log.IsTraceEnabled) + if (log.IsEnabled(LogLevel.Trace)) { log.Trace("Retrying " + invocation.Method.Name); } diff --git a/src/Spring/Spring.Core/Context/Attributes/AssemblyObjectDefinitionScanner.cs b/src/Spring/Spring.Core/Context/Attributes/AssemblyObjectDefinitionScanner.cs index 9ce70e62..1c835890 100644 --- a/src/Spring/Spring.Core/Context/Attributes/AssemblyObjectDefinitionScanner.cs +++ b/src/Spring/Spring.Core/Context/Attributes/AssemblyObjectDefinitionScanner.cs @@ -19,6 +19,7 @@ #endregion using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Support; using Spring.Stereotype; using Spring.Util; @@ -73,7 +74,7 @@ namespace Spring.Context.Attributes string objectName = ObjectNameGenerator.GenerateObjectName(definition, registry); string fullname = type.FullName; - Logger.Debug(m => m("Register Type: {0} with object name '{1}'", fullname, objectName)); + Logger.LogDebug("Register Type: {FullName} with object name {ObjectName}", fullname, objectName); registry.RegisterObjectDefinition(objectName, definition); } } @@ -125,7 +126,7 @@ namespace Spring.Context.Attributes } catch (AmbiguousMatchException) { - Logger.Error(m => m("Type {0} has more than one ComponentAttributes assigned to it.", type.FullName)); + Logger.LogError("Type {Type} has more than one ComponentAttributes assigned to it.", type.FullName); return false; } } diff --git a/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeScanner.cs b/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeScanner.cs index 22843175..7b3aa17d 100644 --- a/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeScanner.cs +++ b/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeScanner.cs @@ -19,6 +19,7 @@ #endregion using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Context.Attributes.TypeFilters; using Spring.Util; using Spring.Objects.Factory.Xml; @@ -177,7 +178,10 @@ namespace Spring.Context.Attributes { if (IsCompoundPredicateSatisfiedBy(type)) { - Logger.Debug(m => m("Satisfied Type: {0}", type.FullName)); + if (Logger.IsEnabled(LogLevel.Debug)) + { + Logger.LogDebug("Satisfied Type: {FullName}", type.FullName); + } types.Add(type); } } @@ -249,12 +253,14 @@ namespace Spring.Context.Attributes private List GetAllAssembliesInPath(string folderPath) { - var assemblies = new List(); assemblies.AddRange(DiscoverAssemblies(folderPath, "*.dll")); assemblies.AddRange(DiscoverAssemblies(folderPath, "*.exe")); - Logger.Debug(m => m("Assemblies to be scanned: {0}", StringUtils.ArrayToCommaDelimitedString(assemblies.ToArray()))); + if (Logger.IsEnabled(LogLevel.Debug)) + { + Logger.LogDebug("Assemblies to be scanned: {AssemblyNames}", StringUtils.ArrayToCommaDelimitedString(assemblies.ToArray())); + } return assemblies; } @@ -274,7 +280,7 @@ namespace Spring.Context.Attributes if (null != loadedAssembly) { string fullname = loadedAssembly.FullName; - Logger.Debug(m => m("Add Assembly: {0}", fullname)); + Logger.LogDebug("Add Assembly: {FullName}", fullname); assemblies.Add(loadedAssembly); } @@ -295,7 +301,7 @@ namespace Spring.Context.Attributes catch (Exception ex) { //log and swallow everything that might go wrong here... - Logger.Debug(m => m("Failed to load assembly {0} to inspect for [Configuration] types!", filename), ex); + Logger.LogDebug(ex, "Failed to load assembly {FileName} to inspect for [Configuration] types!", filename); } return assembly; @@ -315,10 +321,12 @@ namespace Spring.Context.Attributes /// protected virtual IEnumerable ApplyAssemblyFiltersTo(IEnumerable assemblyCandidates) { - var filteredAssemblies = assemblyCandidates.Where(IsIncludedAssembly). - AsEnumerable(); + var filteredAssemblies = assemblyCandidates.Where(IsIncludedAssembly).ToList(); - Logger.Debug(m => m("Filtered Assemblies: {0}", StringUtils.ArrayToCommaDelimitedString(filteredAssemblies.ToArray()))); + if (Logger.IsEnabled(LogLevel.Debug)) + { + Logger.LogDebug("Filtered Assemblies: {0}", StringUtils.ArrayToCommaDelimitedString(filteredAssemblies)); + } return filteredAssemblies; } @@ -360,9 +368,9 @@ namespace Spring.Context.Attributes { if (include(assembly)) { - if (Logger.IsDebugEnabled) + if (Logger.IsEnabled(LogLevel.Debug)) { - Logger.Debug(m => m("Include Assembly: {0}", assembly.FullName)); + Logger.LogDebug("Include Assembly: {FullName}", assembly.FullName); } return true; } @@ -424,7 +432,7 @@ namespace Spring.Context.Attributes { IList assemblies = new List(); - IEnumerable files = Directory.GetFiles(folderPath, extension, SearchOption.AllDirectories); + string[] files = Directory.GetFiles(folderPath, extension, SearchOption.AllDirectories); foreach (string file in files) { diff --git a/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeSource.cs b/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeSource.cs index 9d74687e..d538005d 100644 --- a/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeSource.cs +++ b/src/Spring/Spring.Core/Context/Attributes/AssemblyTypeSource.cs @@ -20,6 +20,7 @@ using System.Collections; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Util; namespace Spring.Context.Attributes @@ -63,12 +64,12 @@ namespace Spring.Context.Attributes catch (ReflectionTypeLoadException ex) { //log and swallow everything that might go wrong here... - Logger.Debug(m => m("Failed to get types " + ex.LoaderExceptions), ex); + Logger.LogDebug(ex, "Failed to get types {LoaderExceptions}", ex.LoaderExceptions); } catch (Exception ex) { //log and swallow everything that might go wrong here... - Logger.Debug(m => m("Failed to get types "), ex); + Logger.LogDebug(ex, "Failed to get types"); } diff --git a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs index 9e1f07bc..e8933c47 100644 --- a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs +++ b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassEnhancer.cs @@ -21,7 +21,7 @@ using System.Collections; using System.Reflection; using System.Reflection.Emit; - +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Config; using Spring.Util; using Spring.Proxy; @@ -115,12 +115,12 @@ namespace Spring.Context.Attributes if (this._configurableListableObjectFactory.IsCurrentlyInCreation(objectName)) { - Logger.Debug(m => m("Object '{0}' currently in creation, created one", objectName)); + Logger.LogDebug("Object '{ObjectName}' currently in creation, created one", objectName); return false; } - Logger.Debug(m => m("Object '{0}' not in creation, asked the application context for one", objectName)); + Logger.LogDebug("Object '{ObjectName}' not in creation, asked the application context for one", objectName); instance = this._configurableListableObjectFactory.GetObject(objectName); return true; diff --git a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs index c55db6b5..2be394fc 100644 --- a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs +++ b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs @@ -21,6 +21,7 @@ #region using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Core.TypeResolution; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Parsing; @@ -98,8 +99,7 @@ namespace Spring.Context.Attributes String configObjectName = ObjectDefinitionReaderUtils.RegisterWithGeneratedName(configObjectDef, _registry); configClass.ObjectName = configObjectName; - Logger.Debug(m => m("Registered object definition for imported [Configuration] class {0}", - configObjectName)); + Logger.LogDebug("Registered object definition for imported [Configuration] class {ObjectName}", configObjectName); } } @@ -209,9 +209,7 @@ namespace Spring.Context.Attributes { // no -> then it's an external override, probably XML // overriding is legal, return immediately - Logger.Debug(m => m("Skipping loading Object definition for {0}: a definition for object " + - "'{1}' already exists. This is likely due to an override in XML.", method, - objectName)); + Logger.LogDebug("Skipping loading Object definition for {Method}: a definition for object {ObjectName} already exists. This is likely due to an override in XML.", method, objectName); return; } } @@ -258,8 +256,7 @@ namespace Spring.Context.Attributes (Attribute.GetCustomAttribute(metadata, typeof(ScopeAttribute)) as ScopeAttribute).ObjectScope.ToString(); } - Logger.Debug(m => m("Registering Object definition for [ObjectDef] method {0}.{1}()", - configClass.ConfigurationClassType.Name, objectName)); + Logger.LogDebug("Registering Object definition for [ObjectDef] method {TypeName}.{ObjectName}()", configClass.ConfigurationClassType.Name, objectName); _registry.RegisterObjectDefinition(objectName, objDef); } diff --git a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassPostProcessor.cs b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassPostProcessor.cs index 574d9dc0..ebd55311 100644 --- a/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassPostProcessor.cs +++ b/src/Spring/Spring.Core/Context/Attributes/ConfigurationClassPostProcessor.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Objects.Factory; using Spring.Objects.Factory.Parsing; @@ -127,7 +128,7 @@ namespace Spring.Context.Attributes Type configClass = objDef.ObjectType; Type enhancedClass = enhancer.Enhance(configClass); - Logger.Debug(m => m("Replacing object definition '{0}' existing class '{1}' with enhanced class", name, configClass.FullName)); + Logger.LogDebug("Replacing object definition '{Name}' existing class '{FullName}' with enhanced class", name, configClass.FullName); ((IConfigurableObjectDefinition)objDef).ObjectType = enhancedClass; } diff --git a/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs b/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs index 053a0772..a1c20500 100644 --- a/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs +++ b/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Objects; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -33,7 +34,7 @@ namespace Spring.Context.Attributes /// public class ScannedGenericObjectDefinition : GenericObjectDefinition { - private static readonly ILog Log = LogManager.GetCurrentClassLogger(); + private static readonly ILog Log = LogManager.GetLogger(); /// /// Name provided by the Component Attribute @@ -57,7 +58,10 @@ namespace Spring.Context.Attributes ParseScopeAttribute(); ParseQualifierAttribute(); - Log.Debug(m => m("ComponentName: {0}; {1}", _componentName, ToString())); + if (Log.IsEnabled(LogLevel.Debug)) + { + Log.LogDebug("ComponentName: {ComponentNAme}; {Name}", _componentName, ToString()); + } } private void ParseName() diff --git a/src/Spring/Spring.Core/Context/Config/ComponentScanObjectDefinitionParser.cs b/src/Spring/Spring.Core/Context/Config/ComponentScanObjectDefinitionParser.cs index 72903caf..d626bb7f 100644 --- a/src/Spring/Spring.Core/Context/Config/ComponentScanObjectDefinitionParser.cs +++ b/src/Spring/Spring.Core/Context/Config/ComponentScanObjectDefinitionParser.cs @@ -20,6 +20,7 @@ using System.ComponentModel; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Context.Attributes; using Spring.Context.Attributes.TypeFilters; using Spring.Objects.Factory.Config; @@ -101,7 +102,7 @@ namespace Spring.Context.Config foreach (var baseAssembly in baseAssemblies.Split(',')) { - if (Logger.IsDebugEnabled) + if (Logger.IsEnabled(LogLevel.Debug)) Logger.Debug("Start With Assembly Filter: " + baseAssembly); scanner.WithAssemblyFilter(assy => assy.FullName.StartsWith(baseAssembly)); @@ -114,7 +115,7 @@ namespace Spring.Context.Config var nameGenerator = CustomTypeFactory.GetNameGenerator(nameGeneratorString); if (nameGenerator != null) { - Logger.Debug(m => m("Use NameTable Generator: {0}", nameGeneratorString)); + Logger.LogDebug("Use NameTable Generator: {NameGenerator}", nameGeneratorString); scanner.ObjectNameGenerator = nameGenerator; } } @@ -126,13 +127,13 @@ namespace Spring.Context.Config if (node.Name.Contains(INCLUDE_FILTER_ELEMENT)) { var filter = CreateTypeFilter(node); - Logger.Debug(m => m("Inlude Filter: {0}", filter)); + Logger.LogDebug("Include Filter: {Filter}", filter); scanner.WithIncludeFilter(filter); } else if (node.Name.Contains(EXCLUDE_FILTER_ELEMENT)) { var filter = CreateTypeFilter(node); - Logger.Debug(m => m("Exclude Filter: {0}", filter)); + Logger.LogDebug("Exclude Filter: {Filter}", filter); scanner.WithExcludeFilter(filter); } } diff --git a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs index c4c46acb..22c605d1 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs @@ -16,6 +16,7 @@ using System.Diagnostics; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Context.Events; using Spring.Core; using Spring.Core.IO; @@ -106,7 +107,7 @@ namespace Spring.Context.Support public static readonly string EventRegistryObjectName = "eventRegistry"; /// - /// The instance for this class. + /// The instance for this class. /// protected readonly ILog log; @@ -238,7 +239,7 @@ namespace Spring.Context.Support GC.SuppressFinalize(this); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, @@ -584,7 +585,7 @@ namespace Spring.Context.Support InvokeObjectFactoryPostProcessors(nonOrderedPostProcessors, SafeGetObjectFactory()); } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"processed {factoryProcessorNames.Count} IFactoryObjectPostProcessors defined in application context [{Name}]."); } @@ -645,7 +646,7 @@ namespace Spring.Context.Support SafeGetObjectFactory().AddObjectPostProcessor(objectPostProcessor); } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"processed {objectProcessors.Count} IObjectPostProcessors defined in application context [{Name}]."); @@ -685,7 +686,7 @@ namespace Spring.Context.Support { _eventRegistry = new EventRegistry(); - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn(string.Format( "Found object in context named '{0}' : this name " + @@ -699,7 +700,7 @@ namespace Spring.Context.Support { _eventRegistry = new EventRegistry(); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"No IEventRegistry found with name '{EventRegistryObjectName}' : using default '{EventRegistry}'."); @@ -762,7 +763,7 @@ namespace Spring.Context.Support } } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(StringUtils.Surround( "Using MessageSource [", MessageSource, "]")); @@ -773,7 +774,7 @@ namespace Spring.Context.Support _messageSource = new DelegatingMessageSource( GetInternalParentMessageSource()); - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn(string.Format( "Found object in context named '{0}' : this name " + @@ -789,7 +790,7 @@ namespace Spring.Context.Support GetInternalParentMessageSource()); SafeGetObjectFactory().RegisterSingleton(MessageSourceObjectName, _messageSource); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( "No message source found in the current context: using parent context's message source '{0}'.", @@ -801,7 +802,7 @@ namespace Spring.Context.Support _messageSource = new StaticMessageSource(); SafeGetObjectFactory().RegisterSingleton(MessageSourceObjectName, _messageSource); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( "No IMessageSource found with name '{0}' : using default '{1}'.", @@ -856,7 +857,7 @@ namespace Spring.Context.Support OnPreRefresh(); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("ApplicationContext Refresh: Refreshing object factory ")); } @@ -865,26 +866,26 @@ namespace Spring.Context.Support IConfigurableListableObjectFactory objectFactory = ObjectFactory; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("ApplicationContext Refresh: Registering well-known processors and objects")); } PrepareObjectFactory(objectFactory); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("ApplicationContext Refresh: Custom post processing object factory")); } PostProcessObjectFactory(objectFactory); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("ApplicationContext Refresh: Post processing object factory using pre-registered processors")); } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, @@ -893,7 +894,7 @@ namespace Spring.Context.Support Name)); } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("ApplicationContext Refresh: Post processing object factory using defined processors")); } @@ -908,7 +909,7 @@ namespace Spring.Context.Support OnRefresh(); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("ApplicationContext Refresh: Preinstantiating singletons")); } @@ -917,7 +918,7 @@ namespace Spring.Context.Support OnPostRefresh(); - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info(string.Format("ApplicationContext Refresh: Completed")); } @@ -2335,7 +2336,7 @@ namespace Spring.Context.Support /// public void PublishEvent(object sender, ApplicationEventArgs e) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, @@ -2372,7 +2373,7 @@ namespace Spring.Context.Support { if (_objectFactory.ObjectPostProcessorCount < _objectPostProcessorTargetCount) { - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info(string.Format( "Object '{0}' is not eligible for being processed by all " + diff --git a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs index 1e898300..0a4f644c 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Objects; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -145,7 +146,7 @@ namespace Spring.Context.Support #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( diff --git a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs index 1db50d1a..14168b7a 100644 --- a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs +++ b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs @@ -23,6 +23,7 @@ using System.Configuration; using System.Reflection; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Core.TypeResolution; using Spring.Reflection.Dynamic; @@ -263,7 +264,7 @@ namespace Spring.Context.Support } #region Instrumentation - if (Log.IsDebugEnabled) Log.Debug(string.Format("creating context '{0}'", contextName ) ); + if (Log.IsEnabled(LogLevel.Debug)) Log.Debug(string.Format("creating context '{0}'", contextName ) ); #endregion IApplicationContext context = null; @@ -292,7 +293,7 @@ namespace Spring.Context.Support IList childContexts = GetChildContexts(contextElement); CreateChildContexts(context, configContext, childContexts); - if (Log.IsDebugEnabled) Log.Debug( string.Format("context '{0}' created for name '{1}'", context, contextName) ); + if (Log.IsEnabled(LogLevel.Debug)) Log.Debug( string.Format("context '{0}' created for name '{1}'", context, contextName) ); } catch (Exception ex) { diff --git a/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs b/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs index 69c6298b..37fbca2c 100644 --- a/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs +++ b/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Context.Events; using Spring.Util; @@ -44,7 +45,7 @@ namespace Spring.Context.Support public sealed class ContextRegistry { /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// private static readonly ILog log = LogManager.GetLogger(typeof(ContextRegistry)); @@ -171,7 +172,7 @@ namespace Spring.Context.Support #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(String.Format("Registering context '{0}' under name '{1}'.", context, context.Name)); } @@ -287,7 +288,7 @@ namespace Spring.Context.Support #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(String.Format( "Returning context '{0}' registered under name '{1}'.", ctx, name)); @@ -321,7 +322,7 @@ namespace Spring.Context.Support // contexts will be removed from contextMap during OnContextEvent handler // but someone might choose to override AbstractApplicationContext.Dispose() without // calling base.Dispose() ... - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { if (instance.contextMap.Count > 0) { diff --git a/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs b/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs index d0e5b923..92f79ca1 100644 --- a/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs +++ b/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs @@ -22,6 +22,7 @@ using System.ComponentModel; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Util; #endregion @@ -181,7 +182,7 @@ namespace Spring.Core.IO { #region Instrumentation - if (_log.IsWarnEnabled) + if (_log.IsEnabled(LogLevel.Warning)) { _log.Warn(string.Format( CultureInfo.InvariantCulture, diff --git a/src/Spring/Spring.Core/LogManager.cs b/src/Spring/Spring.Core/LogManager.cs new file mode 100644 index 00000000..aa452699 --- /dev/null +++ b/src/Spring/Spring.Core/LogManager.cs @@ -0,0 +1,47 @@ +#region License +// /* +// * Copyright 2018 the original author or authors. +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +#endregion + +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Spring; + +public static class LogManager +{ + /// + /// Gets or sets the current log provider based on logger factory. + /// + public static ILoggerFactory LoggerFactory { get; set; } + + public static ILogger GetLogger(string category) => LoggerFactory?.CreateLogger(category) ?? NullLogger.Instance; + public static ILogger GetLogger(Type type) => LoggerFactory?.CreateLogger(type) ?? NullLogger.Instance; + public static ILogger GetLogger() => LoggerFactory?.CreateLogger() ?? NullLogger.Instance; +} + +// TODO INLINE AND REMOVE +public static class LoggerExtensions +{ + public static void Debug(this ILogger logger, string message) => logger.LogDebug(message); + public static void Debug(this ILogger logger, string message, Exception exception) => logger.LogDebug(exception, message); + public static void Trace(this ILogger logger, string message) => logger.LogTrace(message); + public static void Info(this ILogger logger, string message) => logger.LogInformation(message); + public static void Warn(this ILogger logger, string message) => logger.LogWarning(message); + public static void Warn(this ILogger logger, string message, Exception exception) => logger.LogWarning(exception, message); + public static void Error(this ILogger logger, string message) => logger.LogError(message); + public static void Error(this ILogger logger, string message, Exception exception) => logger.LogError(exception, message); +} diff --git a/src/Spring/Spring.Core/Objects/Factory/Attributes/AutowiredAttributeObjectPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Attributes/AutowiredAttributeObjectPostProcessor.cs index ddeb97da..5afdfee9 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Attributes/AutowiredAttributeObjectPostProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Attributes/AutowiredAttributeObjectPostProcessor.cs @@ -19,9 +19,12 @@ #endregion using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Core; using Spring.Objects.Factory.Config; + + using Spring.Objects.Factory.Support; using Spring.Util; @@ -393,13 +396,13 @@ namespace Spring.Objects.Factory.Attributes { if (method.IsStatic) { - logger.Warn(m => m("Autowired annotation is not supported on static methods: " + method.Name)); + logger.LogWarning("Autowired annotation is not supported on static methods: {MethodName}", method.Name); continue; } if (method.IsGenericMethod) { - logger.Warn(m => m("Autowired annotation is not supported on generic methods: " + method.Name)); + logger.LogWarning("Autowired annotation is not supported on generic methods: {MethodName}", method.Name); continue; } @@ -439,7 +442,7 @@ namespace Spring.Objects.Factory.Attributes if (!dependsOn.Contains(autowiredObjectName)) { dependsOn.Add(autowiredObjectName); - logger.Debug(m => m("Autowiring by type from object name '{0}' to object named '{1}'", objectName, autowiredObjectName)); + logger.LogDebug("Autowiring by type from object name '{ObjectName}' to object named '{AutoWiredObjectName}'", objectName, autowiredObjectName); } } objectDefinition.DependsOn = dependsOn; diff --git a/src/Spring/Spring.Core/Objects/Factory/Attributes/InitDestroyAttributeObjectPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Attributes/InitDestroyAttributeObjectPostProcessor.cs index c588626f..477ac969 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Attributes/InitDestroyAttributeObjectPostProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Attributes/InitDestroyAttributeObjectPostProcessor.cs @@ -19,6 +19,7 @@ #endregion using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Config; using Spring.Core; @@ -195,7 +196,7 @@ namespace Spring.Objects.Factory.Attributes Attribute.GetCustomAttribute(methodInfo, initAttributeType) as PostConstructAttribute; if (initAttribute != null && methodInfo.DeclaringType == instanceType) { - logger.Debug(m => m("Found init method on class [{0}]: {1}", instanceType.Name, methodInfo.Name)); + logger.LogDebug("Found init method on class [{InstanceType}]: {MethodName}", instanceType.Name, methodInfo.Name); curInitMethods.Add(new LifecycleElement(methodInfo, initAttribute.Order)); } @@ -203,8 +204,7 @@ namespace Spring.Objects.Factory.Attributes Attribute.GetCustomAttribute(methodInfo, destroyAttributeType) as PreDestroyAttribute; if (destroyAttribute != null && methodInfo.DeclaringType == instanceType) { - logger.Debug( - m => m("Found destroy method on class [{0}]: {1}", instanceType.Name, methodInfo.Name)); + logger.LogDebug("Found destroy method on class [{InstanceType}]: {MethodName}", instanceType.Name, methodInfo.Name); curDestroyMethods.Add(new LifecycleElement(methodInfo, destroyAttribute.Order)); } } @@ -302,7 +302,7 @@ namespace Spring.Objects.Factory.Attributes public void Invoke(object instance, string objectName) { - logger.Debug(m => m("Invoking init method on object '" + objectName + "': " + method.Name)); + logger.LogDebug("Invoking init method on object {ObjectName}: {MethodName}", objectName, method.Name); method.Invoke(instance, new object[] {}); } } diff --git a/src/Spring/Spring.Core/Objects/Factory/Attributes/InjectionMetadata.cs b/src/Spring/Spring.Core/Objects/Factory/Attributes/InjectionMetadata.cs index dfc31a1f..3e060875 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Attributes/InjectionMetadata.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Attributes/InjectionMetadata.cs @@ -19,6 +19,7 @@ #endregion using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Support; namespace Spring.Objects.Factory.Attributes @@ -46,7 +47,7 @@ namespace Spring.Objects.Factory.Attributes { foreach (var element in elements) { - Logger.Debug(m => m("Found injected element on class [" + targetType.Name + "]: " + element)); + Logger.LogDebug("Found injected element on class [{TargetType}]: {Element}", targetType.Name, element); _injectedElements.Add(element); } } @@ -70,7 +71,7 @@ namespace Spring.Objects.Factory.Attributes for (var i = 0; i < _injectedElements.Count; i++) { var element = _injectedElements[i]; - Logger.Debug(m => m("Processing injected method of bean '{0}': {1}", objectName, element)); + Logger.LogDebug("Processing injected method of bean '{ObjectName}': {Element}", objectName, element); element.Inject(instance, objectName, pvs); } } diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ConfigurationReader.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ConfigurationReader.cs index a4d886c6..fb2462ce 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/ConfigurationReader.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/ConfigurationReader.cs @@ -23,10 +23,11 @@ using System.Configuration; using System.Reflection; using System.Runtime.InteropServices; using System.Xml; + + using Spring.Core.IO; using Spring.Core.TypeResolution; using Spring.Util; -using ConfigurationException=Common.Logging.ConfigurationException; using ConfigXmlDocument = Spring.Util.ConfigXmlDocument; namespace Spring.Objects.Factory.Config diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/LogFactoryObject.cs b/src/Spring/Spring.Core/Objects/Factory/Config/LogFactoryObject.cs index e97ba4e2..3b6b9a34 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/LogFactoryObject.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/LogFactoryObject.cs @@ -24,11 +24,11 @@ namespace Spring.Objects.Factory.Config { /// /// implementation that - /// creates instances of the class. + /// creates instances of the class. /// /// ///

- /// Typically used for retrieving shared + /// Typically used for retrieving shared /// instances for common topics (such as the 'DAL', 'BLL', etc). The /// /// property determines the name of the @@ -36,7 +36,7 @@ namespace Spring.Objects.Factory.Config ///

///
/// Rick Evans - /// + /// [Serializable] public class LogFactoryObject : IFactoryObject, IInitializingObject { @@ -57,7 +57,7 @@ namespace Spring.Objects.Factory.Config /// class. ///
/// - /// The name of the instance served up by + /// The name of the instance served up by /// this factory. /// /// @@ -72,11 +72,11 @@ namespace Spring.Objects.Factory.Config #endregion /// - /// The name of the instance served up by + /// The name of the instance served up by /// this factory. /// /// - /// The name of the instance served up by + /// The name of the instance served up by /// this factory. /// /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyOverrideConfigurer.cs b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyOverrideConfigurer.cs index 669a2e5d..11e222fb 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyOverrideConfigurer.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyOverrideConfigurer.cs @@ -20,6 +20,7 @@ using System.Collections.Specialized; using System.Globalization; +using Microsoft.Extensions.Logging; namespace Spring.Objects.Factory.Config { @@ -173,7 +174,7 @@ namespace Spring.Objects.Factory.Config { #region Instrumentation - if (_logger.IsWarnEnabled) + if (_logger.IsEnabled(LogLevel.Warning)) { _logger.Warn(string.Format(CultureInfo.InvariantCulture, "Cannot find object '{0}' when overriding properties; check configuration.", name)); @@ -184,7 +185,7 @@ namespace Spring.Objects.Factory.Config #region Instrumentation - if (_logger.IsDebugEnabled) + if (_logger.IsEnabled(LogLevel.Debug)) { _logger.Debug(string.Format(CultureInfo.InvariantCulture, "Property '{0}' set to '{1}'.", key, value)); diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs index 1baaf88d..de70e5ca 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs @@ -20,6 +20,7 @@ using System.Collections.Specialized; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Util; @@ -239,8 +240,7 @@ namespace Spring.Objects.Factory.Config if (definition == null) { - logger.ErrorFormat("'{0}' can't be found in factorys' '{1}' object definition (includeAncestor {2})", - name, factory, includeAncestors); + logger.LogError("{Name} can't be found in factorys' {Factory} object definition (includeAncestor {IncludeAncestor})", name, factory, includeAncestors); continue; } @@ -302,7 +302,7 @@ namespace Spring.Objects.Factory.Config #region Instrumentation - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format( CultureInfo.InvariantCulture, diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyResourceConfigurer.cs b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyResourceConfigurer.cs index 036d06da..9b8a3a64 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyResourceConfigurer.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyResourceConfigurer.cs @@ -20,6 +20,7 @@ using System.Collections.Specialized; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Core.IO; @@ -269,7 +270,7 @@ namespace Spring.Objects.Factory.Config { #region Instrumentation - if (_log.IsDebugEnabled) + if (_log.IsEnabled(LogLevel.Debug)) { _log.Debug(string.Format( CultureInfo.InvariantCulture, @@ -298,7 +299,7 @@ namespace Spring.Objects.Factory.Config { #region Instrumentation - if (_log.IsWarnEnabled) + if (_log.IsEnabled(LogLevel.Warning)) { _log.Warn(errorMessage); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/SharedStateAwareProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Config/SharedStateAwareProcessor.cs index 241e69b2..2dc62c58 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/SharedStateAwareProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/SharedStateAwareProcessor.cs @@ -19,6 +19,7 @@ #endregion using System.Collections; + using Spring.Core; using Spring.Util; diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs b/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs index a14fbedc..dd53665d 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs @@ -16,6 +16,7 @@ using System.Collections; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Core; using Spring.Util; @@ -298,7 +299,7 @@ namespace Spring.Objects.Factory.Config string resolvedValue = variableSource.ResolveVariable(placeholder); resolvedValue = ParseAndResolveVariables(resolvedValue, visitedPlaceholders); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug(string.Format( CultureInfo.InvariantCulture, diff --git a/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs b/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs index 6140e777..ff4e70d7 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs @@ -18,6 +18,8 @@ #endregion +using Microsoft.Extensions.Logging; + namespace Spring.Objects.Factory.Parsing { public class FailFastProblemReporter : IProblemReporter @@ -37,7 +39,7 @@ namespace Spring.Objects.Factory.Parsing public void Fatal(Problem problem) { - _logger.Fatal(problem.Message); + _logger.LogCritical(problem.Message); throw new ObjectDefinitionParsingException(problem); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs index 453f6b2b..bd41362c 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Collections.Concurrent; using System.Globalization; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Core.TypeResolution; using Spring.Objects.Factory.Config; @@ -288,7 +289,7 @@ namespace Spring.Objects.Factory.Support /// protected object ApplyObjectPostProcessorsBeforeInstantiation(Type objectType, string objectName) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Invoking IInstantiationAwareObjectPostProcessors before " + $"the instantiation of '{objectName}'."); @@ -323,7 +324,7 @@ namespace Spring.Objects.Factory.Support /// public virtual void ApplyObjectPostProcessBeforeDestruction(object instance, string name) { - log.Debug(m => m("Invoking PostProcessBeforeDestruction after IDisposal of object '" + name + "'")); + log.LogDebug("Invoking PostProcessBeforeDestruction after IDisposal of object '{ObjectName}", name); for (var i = 0; i < ObjectPostProcessors.Count; i++) { @@ -336,8 +337,7 @@ namespace Spring.Objects.Factory.Support } catch (Exception ex) { - log.ErrorFormat( - $"Error during execution of {processor.GetType().Name}.PostProcessBeforeDestruction for object {name}", ex); + log.LogError(ex, "Error during execution of {ProcessorName}.PostProcessBeforeDestruction for object {ObjectName}", processor.GetType().Name, name); } } } @@ -656,7 +656,7 @@ namespace Spring.Objects.Factory.Support object o = GetObject(propertyName); properties.Add(propertyName, o); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, @@ -666,7 +666,7 @@ namespace Spring.Objects.Factory.Support } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, @@ -712,7 +712,7 @@ namespace Spring.Objects.Factory.Support { properties.Add(propertyName, ObjectUtils.EnumerateFirstElement(matchingObjects.Values)); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, @@ -731,7 +731,7 @@ namespace Spring.Objects.Factory.Support } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, "Not autowiring property '{0}' of object '{1}': no matching object found.", @@ -844,7 +844,7 @@ namespace Spring.Objects.Factory.Support } } - var isDebugEnabled = log.IsDebugEnabled; + var isDebugEnabled = log.IsEnabled(LogLevel.Debug); if (isDebugEnabled) { log.Debug($"Creating instance of Object '{name}' with merged definition [{definition}]."); @@ -1257,7 +1257,7 @@ namespace Spring.Objects.Factory.Support { if (ObjectUtils.IsAssignableAndNotTransparentProxy(typeof(IInitializingObject), target)) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format(CultureInfo.InvariantCulture, "Calling AfterPropertiesSet() on object with name '{0}'.", name)); } @@ -1266,7 +1266,7 @@ namespace Spring.Objects.Factory.Support } if (StringUtils.HasText(definition.InitMethodName)) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, "Calling custom init method '{0} on object with name '{1}'.", @@ -1374,7 +1374,7 @@ namespace Spring.Objects.Factory.Support { using (new DisposableObjectAdapter(target, name, GetMergedObjectDefinition(name, true), ObjectPostProcessors)) { - log.Debug(m => m("Destroying dependant objects for object '{0}", name)); + log.LogDebug("Destroying dependant objects for object '{ObjectName}", name); DestroyDependantObjects(name); } } @@ -1629,7 +1629,7 @@ namespace Spring.Objects.Factory.Support /// A reference to another object in the factory. protected object ResolveReference(IConfigurableObjectDefinition definition, string name, string argumentName, RuntimeObjectReference reference) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.", @@ -1757,7 +1757,7 @@ namespace Spring.Objects.Factory.Support { object instance = wrapper.WrappedInstance; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"Configuring object using definition '{name}'"); } @@ -1767,7 +1767,7 @@ namespace Spring.Objects.Factory.Support if (ObjectUtils.IsAssignableAndNotTransparentProxy(typeof(IObjectNameAware), instance)) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"Setting the name property on the IObjectNameAware object '{name}'."); } @@ -1777,7 +1777,7 @@ namespace Spring.Objects.Factory.Support if (ObjectUtils.IsAssignableAndNotTransparentProxy(typeof(IObjectFactoryAware), instance)) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"Setting the ObjectFactory property on the IObjectFactoryAware object '{name}'."); @@ -1894,7 +1894,7 @@ namespace Spring.Objects.Factory.Support /// public virtual object ApplyObjectPostProcessorsBeforeInitialization(object instance, string name) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"Invoking IObjectPostProcessors before initialization of object '{name}'"); } @@ -1936,7 +1936,7 @@ namespace Spring.Objects.Factory.Support /// public virtual object ApplyObjectPostProcessorsAfterInitialization(object instance, string name) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"Invoking IObjectPostProcessors after initialization of object '{name}'"); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinitionReader.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinitionReader.cs index 2e0ab446..6cf2ee17 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinitionReader.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinitionReader.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Core.IO; using Spring.Util; @@ -38,7 +39,7 @@ namespace Spring.Objects.Factory.Support #region Constants /// - /// The instance for this class (and derived classes). + /// The instance for this class (and derived classes). /// protected readonly ILog log; @@ -225,7 +226,7 @@ namespace Spring.Objects.Factory.Support } int loadCount = LoadObjectDefinitions(resource); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Loaded " + loadCount + " object definitions from location [" + location + "]"); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs index 51d91a7b..e4b34d72 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs @@ -18,6 +18,8 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Specialized; using System.ComponentModel; + + using Spring.Collections; using Spring.Core; using Spring.Core.TypeConversion; @@ -26,6 +28,7 @@ using Spring.Threading; using Spring.Util; using System.Threading; using System.Runtime.Serialization; +using Microsoft.Extensions.Logging; namespace Spring.Objects.Factory.Support { @@ -60,7 +63,7 @@ namespace Spring.Objects.Factory.Support private static readonly object EmptyObject = new object(); /// - /// The instance for this class. + /// The instance for this class. /// [NonSerialized] protected ILog log; @@ -872,7 +875,7 @@ namespace Spring.Objects.Factory.Support // it's a normal object ? if (!ObjectUtils.IsAssignable(typeof(IFactoryObject), instance)) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Calling code asked for normal instance for name '{0}'.", canonicalName)); } @@ -883,7 +886,7 @@ namespace Spring.Objects.Factory.Support // the user wants the factory itself ? if (!ObjectUtils.IsAssignable(typeof(IFactoryObject), instance) || IsFactoryDereference(name)) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format("Calling code asked for IFactoryObject instance for name '{0}'.", @@ -893,7 +896,7 @@ namespace Spring.Objects.Factory.Support return instance; } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Object with name '{0}' is a factory object.", canonicalName)); } @@ -907,7 +910,7 @@ namespace Spring.Objects.Factory.Support if (resultInstance == null) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Dereferencing Object with name '{0}'", canonicalName)); } @@ -949,7 +952,7 @@ namespace Spring.Objects.Factory.Support } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Returning factory product from cache for Object with name '{0}'", canonicalName)); } @@ -996,7 +999,7 @@ namespace Spring.Objects.Factory.Support { IConfigurableFactoryObject configurableFactory = (IConfigurableFactoryObject)factory; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Factory object with name '{0}' is configurable.", TransformedObjectName(objectName))); } @@ -2095,7 +2098,7 @@ namespace Spring.Objects.Factory.Support object monitor = new object(); const int indent = 3; bool hasErrors = false; - var isDebugEnabled = log.IsDebugEnabled; + var isDebugEnabled = log.IsEnabled(LogLevel.Debug); try { @@ -2222,7 +2225,7 @@ namespace Spring.Objects.Factory.Support CleanupAfterObjectCreationFailure(name); hasErrors = true; - if (log.IsErrorEnabled) + if (log.IsEnabled(LogLevel.Error)) { log.Error(string.Format("{1}GetObjectInternal: error obtaining object {0}", name, new string(' ', nestingCount * indent))); } @@ -2323,7 +2326,7 @@ namespace Spring.Objects.Factory.Support object sharedInstance = singletonCache[objectName]; if (sharedInstance == null) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Creating shared instance of singleton object '{0}'", objectName)); } @@ -2339,7 +2342,7 @@ namespace Spring.Objects.Factory.Support } AddSingleton(objectName, sharedInstance); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Cached shared instance of singleton object '{0}'", objectName)); } @@ -2367,7 +2370,7 @@ namespace Spring.Objects.Factory.Support ///
public virtual void Dispose() { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Destroying singletons in factory [{0}].", this)); } @@ -2519,7 +2522,7 @@ namespace Spring.Objects.Factory.Support if (name == alias) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"Ignoring attempt to Register alias '{alias}' for object with name '{name}' because name and alias would be the same value."); @@ -2528,7 +2531,7 @@ namespace Spring.Objects.Factory.Support return; } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"Registering alias '{alias}' for object with name '{name}'."); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs index a4c0005e..e8792e91 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs @@ -15,6 +15,7 @@ */ using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Core; using Spring.Core.TypeConversion; @@ -90,7 +91,7 @@ namespace Spring.Objects.Factory.Support wrapper.WrappedInstance = instantiationStrategy.Instantiate(rod, objectName, objectFactory, constructorInstantiationInfo.ConstructorInfo, constructorInstantiationInfo.ArgInstances); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"Object '{objectName}' instantiated via constructor [{constructorInstantiationInfo.ConstructorInfo}]."); @@ -346,7 +347,7 @@ namespace Spring.Objects.Factory.Support object objectInstance = instantiationStrategy.Instantiate(definition, name, objectFactory, factoryMethodCandidate, arguments); wrapper.WrappedInstance = objectInstance; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"Object '{name}' instantiated via factory method [{factoryMethodCandidate}]."); } @@ -470,7 +471,7 @@ namespace Spring.Objects.Factory.Support } } - if (log.IsDebugEnabled && autowiredObjectNames != null) + if (log.IsEnabled(LogLevel.Debug) && autowiredObjectNames != null) { for (var i = 0; i < autowiredObjectNames.Count; i++) { diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs index 1c1143fc..1ea475f5 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs @@ -17,6 +17,7 @@ using System.Collections; using System.Collections.Concurrent; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Collections.Generic; using Spring.Core; using Spring.Core.TypeConversion; @@ -362,7 +363,7 @@ namespace Spring.Objects.Factory.Support $"Cannot register object definition [{objectDefinition}] for object '{name}': there's already [{existingDefinition}] bound."); } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"Overriding object definition for object '{name}': replacing [{existingDefinition}] with [{objectDefinition}]."); @@ -464,7 +465,7 @@ namespace Spring.Objects.Factory.Support /// public void PreInstantiateSingletons() { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Pre-instantiating singletons in factory [" + this + "]"); } @@ -992,7 +993,7 @@ namespace Spring.Objects.Factory.Support // ignoring this is ok... it indicates a circular reference when autowiring // constructors; we want to find matches other than the currently // created object itself... - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, @@ -1179,7 +1180,7 @@ namespace Spring.Objects.Factory.Support } // Probably contains a placeholder; lets ignore it for type matching purposes. - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Ignoring object class loading failure for object '" + objectName + "'", ex); } @@ -1192,7 +1193,7 @@ namespace Spring.Objects.Factory.Support } // Probably contains a placeholder; lets ignore it for type matching purposes. - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Ignoring unresolvable metadata in object definition '" + objectName + "'", ex); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DisposableObjectAdapter.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DisposableObjectAdapter.cs index dd2a1037..199d3f0e 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/DisposableObjectAdapter.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/DisposableObjectAdapter.cs @@ -1,4 +1,5 @@ using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Config; using Spring.Util; @@ -126,16 +127,14 @@ namespace Spring.Objects.Factory.Support catch (Exception ex) { - logger.ErrorFormat( - string.Format("Error during execution of {0}.PostProcessBeforeDestruction for object {1}", - processor.GetType().Name, this.objectName), ex); + logger.LogError(ex, "Error during execution of {Type}.PostProcessBeforeDestruction for object {ObjectName}", processor.GetType().Name, this.objectName); } } } if (this.invokeDisposableObject) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Invoking Dispose() on object with name '" + this.objectName + "'"); } @@ -148,7 +147,7 @@ namespace Spring.Objects.Factory.Support catch (Exception ex) { string msg = "Invocation of Dispose method failed on object with name '" + this.objectName + "'"; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Warn(msg, ex); } @@ -216,7 +215,7 @@ namespace Spring.Objects.Factory.Support { args[0] = true; } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Invoking destroy method '" + this.destroyMethodName + "' on object with name '" + this.objectName + "'"); @@ -230,7 +229,7 @@ namespace Spring.Objects.Factory.Support { string msg = "Invocation of destroy method '" + this.destroyMethodName + "' failed on object with name '" + this.objectName + "'"; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Warn(msg, ex.InnerException); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/MethodInjectingInstantiationStrategy.cs b/src/Spring/Spring.Core/Objects/Factory/Support/MethodInjectingInstantiationStrategy.cs index 844bcbae..ea394db0 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/MethodInjectingInstantiationStrategy.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/MethodInjectingInstantiationStrategy.cs @@ -22,7 +22,7 @@ using System.Collections; using System.Globalization; using System.Reflection; using System.Reflection.Emit; - +using Microsoft.Extensions.Logging; using Spring.Util; namespace Spring.Objects.Factory.Support @@ -187,7 +187,7 @@ namespace Spring.Objects.Factory.Support { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format(CultureInfo.InvariantCulture, "Generating a subclass of the [{0}] class for the '{1}' " + diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs index 15cdbb14..3360f676 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs @@ -17,6 +17,7 @@ using System.Collections; using System.Globalization; using System.Runtime.Remoting; +using Microsoft.Extensions.Logging; using Spring.Core.TypeConversion; using Spring.Expressions; using Spring.Objects.Factory.Config; @@ -342,7 +343,7 @@ namespace Spring.Objects.Factory.Support /// A reference to another object in the factory. protected virtual object ResolveReference(IObjectDefinition definition, string name, string argumentName, RuntimeObjectReference reference) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.", diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/PropertiesObjectDefinitionReader.cs b/src/Spring/Spring.Core/Objects/Factory/Support/PropertiesObjectDefinitionReader.cs index e6851819..90c6fde8 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/PropertiesObjectDefinitionReader.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/PropertiesObjectDefinitionReader.cs @@ -21,7 +21,7 @@ using System.Collections; using System.Collections.Specialized; using System.Resources; - +using Microsoft.Extensions.Logging; using Spring.Core.IO; using Spring.Objects.Factory.Config; using Spring.Util; @@ -355,7 +355,7 @@ namespace Spring.Objects.Factory.Support #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Found object name '" + name + "'"); } @@ -375,7 +375,7 @@ namespace Spring.Objects.Factory.Support #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Invalid object name and property [" + nameAndProperty + "]"); } @@ -475,7 +475,7 @@ namespace Spring.Objects.Factory.Support } } } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(pvs.ToString()); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/SimpleInstantiationStrategy.cs b/src/Spring/Spring.Core/Objects/Factory/Support/SimpleInstantiationStrategy.cs index c6ae399e..bd2ad0f5 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/SimpleInstantiationStrategy.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/SimpleInstantiationStrategy.cs @@ -20,6 +20,7 @@ using System.Globalization; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Core.TypeResolution; using Spring.Util; @@ -42,7 +43,7 @@ namespace Spring.Objects.Factory.Support public class SimpleInstantiationStrategy : IInstantiationStrategy { /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected static readonly ILog log = LogManager.GetLogger(typeof(SimpleInstantiationStrategy)); @@ -72,7 +73,7 @@ namespace Spring.Objects.Factory.Support AssertUtils.ArgumentNotNull(definition, "definition"); AssertUtils.ArgumentNotNull(factory, "factory"); - if (log.IsTraceEnabled) log.Trace(string.Format("instantiating object '{0}'", name)); + if (log.IsEnabled(LogLevel.Trace)) log.Trace(string.Format("instantiating object '{0}'", name)); if (definition.HasMethodOverrides) { @@ -198,7 +199,7 @@ namespace Spring.Objects.Factory.Support #region Instrumentation - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn(msg, ex.InnerException); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/DefaultObjectDefinitionDocumentReader.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/DefaultObjectDefinitionDocumentReader.cs index 17565024..e39549d5 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/DefaultObjectDefinitionDocumentReader.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/DefaultObjectDefinitionDocumentReader.cs @@ -16,6 +16,7 @@ using System.Globalization; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Core.IO; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -37,7 +38,7 @@ namespace Spring.Objects.Factory.Xml public class DefaultObjectDefinitionDocumentReader : IObjectDefinitionDocumentReader { /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected static readonly ILog log = LogManager.GetLogger(typeof(DefaultObjectDefinitionDocumentReader)); @@ -80,7 +81,7 @@ namespace Spring.Objects.Factory.Xml this.readerContext = readerContext; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Loading object definitions."); } @@ -96,7 +97,7 @@ namespace Spring.Objects.Factory.Xml PostProcessXml(root); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( $"Found {readerContext.Registry.ObjectDefinitionCount} <{ObjectDefinitionConstants.ObjectElement}> elements defining objects."); @@ -187,7 +188,7 @@ namespace Spring.Objects.Factory.Xml } bdHolder = helper.DecorateObjectDefinitionIfRequired(element, bdHolder); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format(CultureInfo.InvariantCulture, "Registering object definition with id '{0}'.", bdHolder.ObjectName)); } @@ -220,7 +221,7 @@ namespace Spring.Objects.Factory.Xml string location = resource.GetAttribute(ObjectDefinitionConstants.ImportResourceAttribute); try { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs index 2bbeef5e..2f12ee3f 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs @@ -20,6 +20,7 @@ using System.Globalization; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; using Spring.Util; @@ -40,7 +41,7 @@ namespace Spring.Objects.Factory.Xml #region Fields /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected readonly ILog log; @@ -107,7 +108,7 @@ namespace Spring.Objects.Factory.Xml DocumentDefaultsDefinition ddd = new DocumentDefaultsDefinition(); #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Loading object definitions..."); } @@ -118,7 +119,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -132,7 +133,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -146,7 +147,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -160,7 +161,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -174,7 +175,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -188,7 +189,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -202,7 +203,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -216,7 +217,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -230,7 +231,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -338,7 +339,7 @@ namespace Spring.Objects.Factory.Xml { objectName = aliases[0]; aliases.RemoveAt(0); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("No XML 'id' specified using '{0}' as object name and '{1}' as aliases", objectName, string.Join(",", aliases.ToArray()))); } @@ -379,7 +380,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( "Neither XML '{0}' nor '{1}' specified - using generated object name [{2}]", diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs index ddf255e6..0a084e43 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs @@ -24,6 +24,7 @@ using System.Collections; using System.Collections.Specialized; using System.Globalization; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Core.IO; using Spring.Core.TypeResolution; @@ -67,7 +68,7 @@ namespace Spring.Objects.Factory.Xml public const string Namespace = "http://www.springframework.net"; /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected static readonly ILog log = LogManager.GetLogger(typeof(ObjectsNamespaceParser)); @@ -202,7 +203,7 @@ namespace Spring.Objects.Factory.Xml { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, @@ -310,7 +311,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format( @@ -835,7 +836,7 @@ namespace Spring.Objects.Factory.Xml { if (StringUtils.HasText(typeAttr)) { - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn("The 'type' attribute is redundant when the 'name' attribute has been used on a constructor argument element."); } @@ -1464,7 +1465,7 @@ namespace Spring.Objects.Factory.Xml { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format("Error while parsing dependency checking mode : '{0}' is an invalid value.", @@ -1506,7 +1507,7 @@ namespace Spring.Objects.Factory.Xml { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug( string.Format("Error while parsing autowire mode : '{0}' is an invalid value.", diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/XmlObjectDefinitionReader.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/XmlObjectDefinitionReader.cs index 0bc73418..e2b0758c 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/XmlObjectDefinitionReader.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/XmlObjectDefinitionReader.cs @@ -22,6 +22,7 @@ using System.Xml; using System.Xml.Schema; +using Microsoft.Extensions.Logging; using Spring.Core.IO; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -219,7 +220,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Loading XML object definitions from " + resource); } @@ -249,7 +250,7 @@ namespace Spring.Objects.Factory.Xml { #region Instrumentation - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn("Could not close stream.", ex); } @@ -337,7 +338,7 @@ namespace Spring.Objects.Factory.Xml #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Using the following XmlReader implementation : " + reader.GetType()); } @@ -372,7 +373,7 @@ namespace Spring.Objects.Factory.Xml { #region Instrumentation - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn( "Ignored XML validation warning: " + args.Message, diff --git a/src/Spring/Spring.Core/Objects/ObjectWrapper.cs b/src/Spring/Spring.Core/Objects/ObjectWrapper.cs index 3a1074a2..51f5d8c4 100644 --- a/src/Spring/Spring.Core/Objects/ObjectWrapper.cs +++ b/src/Spring/Spring.Core/Objects/ObjectWrapper.cs @@ -17,6 +17,7 @@ using System.ComponentModel; using System.Reflection; using System.Text; + using Spring.Core; using Spring.Expressions; using Spring.Expressions.Parser.antlr; diff --git a/src/Spring/Spring.Core/Objects/Support/AutoWiringEventHandlerValue.cs b/src/Spring/Spring.Core/Objects/Support/AutoWiringEventHandlerValue.cs index e04b8bc8..9f7c118c 100644 --- a/src/Spring/Spring.Core/Objects/Support/AutoWiringEventHandlerValue.cs +++ b/src/Spring/Spring.Core/Objects/Support/AutoWiringEventHandlerValue.cs @@ -20,6 +20,7 @@ using System.Globalization; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Util; @@ -204,7 +205,7 @@ namespace Spring.Objects.Support { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format( CultureInfo.InvariantCulture, diff --git a/src/Spring/Spring.Core/Objects/Support/PropertyComparator.cs b/src/Spring/Spring.Core/Objects/Support/PropertyComparator.cs index 04749a97..b6949af6 100644 --- a/src/Spring/Spring.Core/Objects/Support/PropertyComparator.cs +++ b/src/Spring/Spring.Core/Objects/Support/PropertyComparator.cs @@ -20,6 +20,7 @@ using System.Collections; using System.Globalization; +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Util; @@ -118,7 +119,7 @@ namespace Spring.Objects.Support { #region Instrumentation - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("Could not sort objects [" + o1 + "] and [" + o2 + "]", ex); @@ -160,7 +161,7 @@ namespace Spring.Objects.Support catch (ObjectsException ex) { // if a nested property cannot be read, simply return null... - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Could not access property - treating as null for sorting.", ex); } diff --git a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs index 49973355..c96980fa 100644 --- a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs +++ b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs @@ -50,7 +50,7 @@ namespace Spring.Proxy #region Fields /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected static readonly ILog log = LogManager.GetLogger(typeof(AbstractProxyTypeBuilder)); diff --git a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs index b3f4bcdb..c85a17df 100644 --- a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs +++ b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs @@ -19,6 +19,8 @@ #endregion using System.Reflection; + + using Spring.Util; namespace Spring.Reflection.Dynamic diff --git a/src/Spring/Spring.Core/Spring.Core.csproj b/src/Spring/Spring.Core/Spring.Core.csproj index 582a53b5..8193cd44 100644 --- a/src/Spring/Spring.Core/Spring.Core.csproj +++ b/src/Spring/Spring.Core/Spring.Core.csproj @@ -20,15 +20,18 @@ - - + + + + + + + - - diff --git a/src/Spring/Spring.Core/Util/EventUtils.cs b/src/Spring/Spring.Core/Util/EventUtils.cs index 38a98068..36c03026 100644 --- a/src/Spring/Spring.Core/Util/EventUtils.cs +++ b/src/Spring/Spring.Core/Util/EventUtils.cs @@ -21,6 +21,7 @@ using System.Diagnostics; using System.Reflection; + namespace Spring.Util { /// diff --git a/src/Spring/Spring.Core/Util/ObjectUtils.cs b/src/Spring/Spring.Core/Util/ObjectUtils.cs index 370ad347..7b919c8f 100644 --- a/src/Spring/Spring.Core/Util/ObjectUtils.cs +++ b/src/Spring/Spring.Core/Util/ObjectUtils.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Globalization; using System.Reflection; using System.Runtime.Remoting; +using Microsoft.Extensions.Logging; #if !NETSTANDARD using System.Runtime.Remoting.Proxies; #endif @@ -40,7 +41,7 @@ namespace Spring.Util public sealed class ObjectUtils { /// - /// The instance for this class. + /// The instance for this class. /// private static readonly ILog log = LogManager.GetLogger(typeof(ObjectUtils)); @@ -205,7 +206,7 @@ namespace Spring.Util { AssertUtils.ArgumentNotNull(constructor, "constructor"); - if (log.IsTraceEnabled) log.Trace(string.Format("instantiating type [{0}] using constructor [{1}]", constructor.DeclaringType, constructor)); + if (log.IsEnabled(LogLevel.Trace)) log.Trace(string.Format("instantiating type [{0}] using constructor [{1}]", constructor.DeclaringType, constructor)); if (constructor.DeclaringType.IsInterface) { diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTemplate.cs b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTemplate.cs index 02b62aa7..1725bcbd 100644 --- a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTemplate.cs +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTemplate.cs @@ -15,6 +15,7 @@ */ using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Aop.Framework; using Spring.Data.Common; using Spring.Data.Support; @@ -852,7 +853,7 @@ namespace Spring.Data.NHibernate bool existingTransaction = SessionFactoryUtils.IsSessionTransactional(session, SessionFactory); if (existingTransaction) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Found thread-bound Session for HibernateTemplate"); } @@ -900,7 +901,7 @@ namespace Spring.Data.NHibernate { if (existingTransaction) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Not closing pre-bound Hibernate Session after HibernateTemplate"); } diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTransactionManager.cs b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTransactionManager.cs index b7122700..a8aaf722 100644 --- a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTransactionManager.cs +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTransactionManager.cs @@ -16,7 +16,7 @@ using System.Data; using System.Reflection; - +using Microsoft.Extensions.Logging; using NHibernate; using NHibernate.Transaction; @@ -280,7 +280,7 @@ namespace Spring.Data.NHibernate { SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.GetResource(SessionFactory); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Found thread-bound Session [" + sessionHolder.Session + "] for Hibernate transaction"); @@ -357,7 +357,7 @@ namespace Spring.Data.NHibernate ISession newSession = (interceptor != null ? SessionFactory.OpenSession(interceptor) : SessionFactory.OpenSession()); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Opened new Session [" + newSession + "] for Hibernate transaction"); } @@ -412,7 +412,7 @@ namespace Spring.Data.NHibernate { conHolder.TimeoutInSeconds = timeout; } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Exposing Hibernate transaction as ADO transaction [" + con + "]"); } @@ -729,7 +729,7 @@ namespace Spring.Data.NHibernate ISession session = txObject.SessionHolder.Session; if (txObject.NewSessionHolder) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Closing Hibernate Session [" + session + "] after transaction"); } @@ -737,7 +737,7 @@ namespace Spring.Data.NHibernate } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Not closing pre-bound Hibernate Session [" + session + "] after transaction"); } @@ -936,7 +936,7 @@ namespace Spring.Data.NHibernate if (sfDbProvider != null) { // Use the SessionFactory's DataSource for exposing transactions to ADO.NET code. - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info("Derived DbProvider [" + sfDbProvider.DbMetadata.ProductName + "] of Hibernate SessionFactory for HibernateTransactionManager"); diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTxScopeTransactionManager.cs b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTxScopeTransactionManager.cs index ab1c16ad..ee024124 100644 --- a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTxScopeTransactionManager.cs +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/HibernateTxScopeTransactionManager.cs @@ -17,6 +17,7 @@ using System.Data; using System.Reflection; using System.Transactions; +using Microsoft.Extensions.Logging; using NHibernate; using NHibernate.Transaction; @@ -284,7 +285,7 @@ namespace Spring.Data.NHibernate { SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.GetResource(SessionFactory); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Found thread-bound Session [" + sessionHolder.Session + "] for Hibernate transaction"); @@ -377,7 +378,7 @@ namespace Spring.Data.NHibernate ISession newSession = (interceptor != null ? SessionFactory.OpenSession(interceptor) : SessionFactory.OpenSession()); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Opened new Session [" + newSession + "] for Hibernate transaction"); } @@ -432,7 +433,7 @@ namespace Spring.Data.NHibernate { conHolder.TimeoutInSeconds = timeout; } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Exposing Hibernate transaction as ADO transaction [" + con + "]"); } @@ -930,7 +931,7 @@ namespace Spring.Data.NHibernate if (txObject.NewSessionHolder) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Closing Hibernate Session [" + session + "] after transaction"); } @@ -939,7 +940,7 @@ namespace Spring.Data.NHibernate } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Not closing pre-bound Hibernate Session [" + session + "] after transaction"); } @@ -1098,7 +1099,7 @@ namespace Spring.Data.NHibernate if (sfDbProvider != null) { // Use the SessionFactory's DataSource for exposing transactions to ADO.NET code. - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info("Derived DbProvider [" + sfDbProvider.DbMetadata.ProductName + "] of Hibernate SessionFactory for HibernateTransactionManager"); diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/LocalSessionFactoryObject.cs b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/LocalSessionFactoryObject.cs index 7b30c62b..1bb057a2 100644 --- a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/LocalSessionFactoryObject.cs +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/LocalSessionFactoryObject.cs @@ -17,6 +17,7 @@ using System.Collections; using System.Data; using System.Data.Common; +using Microsoft.Extensions.Logging; using NHibernate; using NHibernate.Bytecode; using NHibernate.Cfg; @@ -487,7 +488,7 @@ namespace Spring.Data.NHibernate if (config.GetProperty(Environment.ConnectionProvider) != null && hibernateProperties.ContainsKey(Environment.ConnectionProvider)) { - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info("Overriding use of Spring's Hibernate Connection Provider with [" + hibernateProperties[Environment.ConnectionProvider] + "]"); @@ -637,7 +638,7 @@ namespace Spring.Data.NHibernate { if (sessionFactory != null) { - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info("Closing Hibernate SessionFactory"); } @@ -833,7 +834,7 @@ namespace Spring.Data.NHibernate /// protected virtual void ExecuteSchemaStatement(IDbCommand cmd, string sql) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Executing schema statement: " + sql); } @@ -844,7 +845,7 @@ namespace Spring.Data.NHibernate } catch (ADOException ex) { - if (log.IsWarnEnabled) + if (log.IsEnabled(LogLevel.Warning)) { log.Warn("Unsuccessful schema statement: " + sql, ex); } diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/SpringSessionSynchronization.cs b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/SpringSessionSynchronization.cs index 1cb395e2..b1274e4c 100644 --- a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/SpringSessionSynchronization.cs +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/SpringSessionSynchronization.cs @@ -1,5 +1,5 @@ /* - * Copyright � 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -246,4 +246,4 @@ namespace Spring.Data.NHibernate } } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/SessionScope.cs b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/SessionScope.cs index 0608fc38..b1f0e02e 100644 --- a/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/SessionScope.cs +++ b/src/Spring/Spring.Data.NHibernate5/Data/NHibernate/Support/SessionScope.cs @@ -15,6 +15,7 @@ */ using System.Reflection; +using Microsoft.Extensions.Logging; using NHibernate; using Spring.Threading; using Spring.Transaction.Support; @@ -311,7 +312,7 @@ namespace Spring.Data.NHibernate.Support throw new InvalidOperationException("This scope is already open"); } - bool isDebugEnabled = log.IsDebugEnabled; + bool isDebugEnabled = log.IsEnabled(LogLevel.Debug); if (SingleSession) { @@ -353,7 +354,7 @@ namespace Spring.Data.NHibernate.Support /// public void Close() { - bool isDebugEnabled = log.IsDebugEnabled; + bool isDebugEnabled = log.IsEnabled(LogLevel.Debug); if (isDebugEnabled) log.Debug("Trying to close SessionScope"); if (IsOpen) @@ -423,7 +424,7 @@ namespace Spring.Data.NHibernate.Support /// public LazySessionHolder(SessionScope owner) { - if (log.IsDebugEnabled) log.Debug("Created LazySessionHolder"); + if (log.IsEnabled(LogLevel.Debug)) log.Debug("Created LazySessionHolder"); this.owner = owner; } @@ -434,7 +435,7 @@ namespace Spring.Data.NHibernate.Support { if (session == null) { - if (log.IsDebugEnabled) log.Debug("session instance requested - opening new session"); + if (log.IsEnabled(LogLevel.Debug)) log.Debug("session instance requested - opening new session"); session = owner.DoOpenSession(); AddSession(session); } @@ -452,7 +453,7 @@ namespace Spring.Data.NHibernate.Support session = null; SessionFactoryUtils.CloseSession(tmpSession); } - if (log.IsDebugEnabled) log.Debug("Closed LazySessionHolder"); + if (log.IsEnabled(LogLevel.Debug)) log.Debug("Closed LazySessionHolder"); } } } diff --git a/src/Spring/Spring.Data/Dao/Support/DaoSupport.cs b/src/Spring/Spring.Data/Dao/Support/DaoSupport.cs index 6147e7ac..c74cdac1 100644 --- a/src/Spring/Spring.Data/Dao/Support/DaoSupport.cs +++ b/src/Spring/Spring.Data/Dao/Support/DaoSupport.cs @@ -39,7 +39,7 @@ namespace Spring.Dao.Support #region Constants /// - /// The shared instance for this class (and derived classes). + /// The shared instance for this class (and derived classes). /// protected static readonly ILog log = LogManager.GetLogger(typeof (DaoSupport)); diff --git a/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs b/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs index 8bc56604..e1a95ff5 100644 --- a/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs +++ b/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs @@ -14,6 +14,7 @@ * limitations under the License. */ +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; using Spring.Core.IO; @@ -111,7 +112,7 @@ namespace Spring.Data.Common if (loader.GetResource(DBPROVIDER_ADDITIONAL_RESOURCE_NAME).Exists) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Loading additional DbProviders from " + DBPROVIDER_ADDITIONAL_RESOURCE_NAME); } @@ -124,7 +125,7 @@ namespace Spring.Data.Common ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME }); } - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { var dbProviderNames = ctx.GetObjectNames(); log.Info( diff --git a/src/Spring/Spring.Data/Data/Common/ErrorCodes.cs b/src/Spring/Spring.Data/Data/Common/ErrorCodes.cs index add01d83..455ea63d 100644 --- a/src/Spring/Spring.Data/Data/Common/ErrorCodes.cs +++ b/src/Spring/Spring.Data/Data/Common/ErrorCodes.cs @@ -18,6 +18,7 @@ #endregion + namespace Spring.Data.Common { /// diff --git a/src/Spring/Spring.Data/Data/Common/MultiDelegatingDbProvider.cs b/src/Spring/Spring.Data/Data/Common/MultiDelegatingDbProvider.cs index 7acf1427..c5cf0cb8 100644 --- a/src/Spring/Spring.Data/Data/Common/MultiDelegatingDbProvider.cs +++ b/src/Spring/Spring.Data/Data/Common/MultiDelegatingDbProvider.cs @@ -20,6 +20,7 @@ using System.Collections; using System.Data; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Dao; using Spring.Objects.Factory; @@ -275,7 +276,7 @@ namespace Spring.Data.Common //Fall back to default if available if (defaultDbProvider != null) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("No DbProvider defined in thread local storage, falling back to use DefaultDbProvider."); } diff --git a/src/Spring/Spring.Data/Data/Core/AdoPlatformTransactionManager.cs b/src/Spring/Spring.Data/Data/Core/AdoPlatformTransactionManager.cs index 8b7dbad1..74287ff5 100644 --- a/src/Spring/Spring.Data/Data/Core/AdoPlatformTransactionManager.cs +++ b/src/Spring/Spring.Data/Data/Core/AdoPlatformTransactionManager.cs @@ -19,6 +19,7 @@ #endregion using System.Data; +using Microsoft.Extensions.Logging; using Spring.Data.Common; using Spring.Data.Support; using Spring.Objects.Factory; @@ -141,7 +142,7 @@ namespace Spring.Data.Core if (txMgrStateObject.ConnectionHolder == null || txMgrStateObject.ConnectionHolder.SynchronizedWithTransaction) { IDbConnection newCon = DbProvider.CreateConnection(); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Acquired Connection [" + newCon + ", " + newCon.ConnectionString + "] for ADO.NET transaction"); } @@ -334,7 +335,7 @@ namespace Spring.Data.Core } IDbConnection con = txMgrStateObject.ConnectionHolder.Connection; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Releasing ADO.NET Connection [" + con + ", " + con.ConnectionString + "] after transaction"); } diff --git a/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs b/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs index 3a365ae6..9d1d6061 100644 --- a/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs +++ b/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs @@ -23,6 +23,7 @@ using System.Data; using System.Data.Common; using System.Globalization; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Dao.Support; using Spring.Data.Common; using Spring.Data.Support; @@ -365,7 +366,7 @@ namespace Spring.Data.Core public virtual int ExecuteNonQuery(CommandType cmdType, string cmdText) { #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing NonQuery " + cmdType + "[" + cmdText + "]"); } @@ -404,7 +405,7 @@ namespace Spring.Data.Core IDbParameters parameters) { #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing NonQuery. " + cmdType + "[" + cmdText + "]"); } @@ -426,7 +427,7 @@ namespace Spring.Data.Core ICommandSetter commandSetter) { #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing NonQuery. " + cmdType + "[" + cmdText + "]"); } @@ -519,7 +520,7 @@ namespace Spring.Data.Core ICommandSetter commandSetter) { #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing ExecuteScalar. " + cmdType + "[" + cmdText + "]"); } @@ -719,7 +720,7 @@ namespace Spring.Data.Core //TODO check for parameter placeholders... - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing SQL [" + sql + "]"); } @@ -770,7 +771,7 @@ namespace Spring.Data.Core //TODO check for parameter placeholders... - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing SQL [" + sql + "]"); } @@ -1136,7 +1137,7 @@ namespace Spring.Data.Core ValidateFillArguments(dataTable, sql); #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DataTableFill " + commandType + "[" + sql + "]"); } @@ -1154,7 +1155,7 @@ namespace Spring.Data.Core ValidateFillArguments(dataTable, sql); #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DataTableFill " + commandType + "[" + sql + "] with table mapping name " + tableMappingName); } @@ -1475,7 +1476,7 @@ namespace Spring.Data.Core ValidateFillArguments(dataSet, sql); #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DataSetFill " + commandType + "[" + sql + "]"); } @@ -1495,7 +1496,7 @@ namespace Spring.Data.Core ValidateFillArguments(dataSet, sql); #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DataSetFill " + commandType + "[" + sql + "] with table names " + tableNames); } @@ -2790,7 +2791,7 @@ namespace Spring.Data.Core commandSetter.SetValues(command); } Object rowsAffected = command.ExecuteNonQuery(); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("ExecuteNonQuery affected " + rowsAffected + " rows"); } @@ -2856,7 +2857,7 @@ namespace Spring.Data.Core commandSetter.SetValues(command); } Object returnValue = command.ExecuteScalar(); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("ExecuteScalar return value = " + returnValue); } diff --git a/src/Spring/Spring.Data/Data/Core/ServiceDomainPlatformTransactionManager.cs b/src/Spring/Spring.Data/Data/Core/ServiceDomainPlatformTransactionManager.cs index 6dc04d42..417737b3 100644 --- a/src/Spring/Spring.Data/Data/Core/ServiceDomainPlatformTransactionManager.cs +++ b/src/Spring/Spring.Data/Data/Core/ServiceDomainPlatformTransactionManager.cs @@ -19,6 +19,7 @@ #endregion using System.EnterpriseServices; +using Microsoft.Extensions.Logging; using Spring.Data.Support; using Spring.Objects.Factory; using Spring.Transaction; @@ -147,7 +148,7 @@ namespace Spring.Data.Core SimpleServiceConfig serviceConfig = CreateServiceConfig(definition); //The context is created when we call Enter. serviceDomainTxObject.ServiceDomainAdapter.Enter(serviceConfig); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Context created. TransactionId = " + ContextUtil.TransactionId + ", ActivityId = " + ContextUtil.ActivityId); @@ -196,7 +197,7 @@ namespace Spring.Data.Core { case System.Data.IsolationLevel.Chaos: - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info("IsolationLevel Chaos does not have a direct counterpart in EnterpriseServices, using Any"); } @@ -215,7 +216,7 @@ namespace Spring.Data.Core serviceConfig.IsolationLevel = TransactionIsolationLevel.Serializable; break; case System.Data.IsolationLevel.Snapshot: - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info("IsolationLevel Snapshot does not have a direct counterpart in EnterpriseServices, using ReadCommitted. Introduced in SqlServer 2005. Consider using System.Transactions for transaction management instead."); } @@ -281,7 +282,7 @@ namespace Spring.Data.Core } } TransactionStatus serviceDomainTxstatus = txObject.ServiceDomainAdapter.Leave(); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("ServiceDomain Transaction Status upon leaving ServiceDomain = " + serviceDomainTxstatus); } diff --git a/src/Spring/Spring.Data/Data/Generic/AdoTemplate.cs b/src/Spring/Spring.Data/Data/Generic/AdoTemplate.cs index 6fb8237b..22b66574 100644 --- a/src/Spring/Spring.Data/Data/Generic/AdoTemplate.cs +++ b/src/Spring/Spring.Data/Data/Generic/AdoTemplate.cs @@ -21,6 +21,7 @@ using System.Collections; using System.Data; using System.Data.Common; +using Microsoft.Extensions.Logging; using Spring.Dao; using Spring.Dao.Support.Generic; using Spring.Data.Common; @@ -870,7 +871,7 @@ namespace Spring.Data.Generic IResultSetExtractor resultSetExtractor) { AssertUtils.ArgumentNotNull(cmdText, "cmdText", "CommandText must not be null"); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing CommandText [" + cmdText + "]"); } @@ -924,7 +925,7 @@ namespace Spring.Data.Generic { AssertUtils.ArgumentNotNull(cmdText, "cmdText", "CommandText must not be null"); AssertUtils.ArgumentNotNull(resultSetExtractorDelegate, "resultSetExtractorDelegate", "Result set extractor delegate must not be null"); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing CommandText [" + cmdText + "]"); } diff --git a/src/Spring/Spring.Data/Data/Objects/AbstractAdoOperation.cs b/src/Spring/Spring.Data/Data/Objects/AbstractAdoOperation.cs index 35525eb5..78ddb664 100644 --- a/src/Spring/Spring.Data/Data/Objects/AbstractAdoOperation.cs +++ b/src/Spring/Spring.Data/Data/Objects/AbstractAdoOperation.cs @@ -326,4 +326,4 @@ namespace Spring.Data.Objects #endregion } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Data/Data/Support/ConnectionUtils.cs b/src/Spring/Spring.Data/Data/Support/ConnectionUtils.cs index 991ce8c3..f553a512 100644 --- a/src/Spring/Spring.Data/Data/Support/ConnectionUtils.cs +++ b/src/Spring/Spring.Data/Data/Support/ConnectionUtils.cs @@ -19,6 +19,7 @@ #endregion using System.Data; +using Microsoft.Extensions.Logging; using Spring.Data.Common; using Spring.Transaction.Support; using Spring.Util; @@ -73,7 +74,7 @@ namespace Spring.Data.Support return; } } - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Disposing of IDbConnection with connection string = [" + dbProvider.ConnectionString + "]"); } @@ -129,7 +130,7 @@ namespace Spring.Data.Support conHolder.Requested(); if (!conHolder.HasConnection) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Fetching resumed ADO.NET connection from DbProvider"); } @@ -139,7 +140,7 @@ namespace Spring.Data.Support } // Else we either got no holder or an empty thread-bound holder here. - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Fetching Connection from DbProvider"); } diff --git a/src/Spring/Spring.Data/Data/Support/ErrorCodeExceptionTranslator.cs b/src/Spring/Spring.Data/Data/Support/ErrorCodeExceptionTranslator.cs index b2de9eac..7b68cebc 100644 --- a/src/Spring/Spring.Data/Data/Support/ErrorCodeExceptionTranslator.cs +++ b/src/Spring/Spring.Data/Data/Support/ErrorCodeExceptionTranslator.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Dao; using Spring.Data.Common; @@ -166,7 +167,7 @@ namespace Spring.Data.Support return dex; } // Looking for a fallback... - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Unable to translate exception with errorCode '" + errorCode + "', will use the fallback translator"); } @@ -323,7 +324,7 @@ namespace Spring.Data.Support /// if set to true [b]. private void LogTranslation(string task, string sql, string errorCode, Exception exception, bool b) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { String intro = "Translating"; log.Debug(intro + " ADO exception with error code '" + errorCode diff --git a/src/Spring/Spring.Data/Transaction/Interceptor/MethodMapTransactionAttributeSource.cs b/src/Spring/Spring.Data/Transaction/Interceptor/MethodMapTransactionAttributeSource.cs index 0b3c326b..bd7b8791 100644 --- a/src/Spring/Spring.Data/Transaction/Interceptor/MethodMapTransactionAttributeSource.cs +++ b/src/Spring/Spring.Data/Transaction/Interceptor/MethodMapTransactionAttributeSource.cs @@ -20,6 +20,7 @@ using System.Collections; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Util; using Spring.Core.TypeResolution; using Spring.Core; @@ -171,7 +172,7 @@ namespace Spring.Transaction.Interceptor { // No already registered method name, or more specific // method name specification now -> (re-)register method. - if (LOG.IsDebugEnabled && regularMethodName != null) + if (LOG.IsEnabled(LogLevel.Debug) && regularMethodName != null) { LOG.Debug("Replacing attribute for transactional method [" + currentMethod + "]: current name '" + name + "' is more specific than '" + regularMethodName + "'"); @@ -181,7 +182,7 @@ namespace Spring.Transaction.Interceptor } else { - if (LOG.IsDebugEnabled && regularMethodName != null) + if (LOG.IsEnabled(LogLevel.Debug) && regularMethodName != null) { LOG.Debug("Keeping attribute for transactional method [" + currentMethod + "]: current name '" + name + "' is not more specific than '" + regularMethodName + "'"); diff --git a/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs b/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs index ff67ec0a..8f386ab9 100644 --- a/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs +++ b/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs @@ -21,6 +21,7 @@ using System.Collections; using System.Collections.Specialized; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Util; namespace Spring.Transaction.Interceptor @@ -157,7 +158,7 @@ namespace Spring.Transaction.Interceptor public void AddTransactionMethod( string methodName, ITransactionAttribute attribute ) { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Adding transactional method [" + methodName + "] with attribute [" + attribute + "]"); } diff --git a/src/Spring/Spring.Data/Transaction/Interceptor/TransactionAspectSupport.cs b/src/Spring/Spring.Data/Transaction/Interceptor/TransactionAspectSupport.cs index 9dcfb969..b75e0491 100644 --- a/src/Spring/Spring.Data/Transaction/Interceptor/TransactionAspectSupport.cs +++ b/src/Spring/Spring.Data/Transaction/Interceptor/TransactionAspectSupport.cs @@ -20,6 +20,7 @@ using System.Collections.Specialized; using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Threading; using Spring.Util; @@ -347,7 +348,7 @@ namespace Spring.Transaction.Interceptor // We need a transaction for this method #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Getting transaction for " + transactionInfo.JoinpointIdentification); } @@ -361,7 +362,7 @@ namespace Spring.Transaction.Interceptor // The TransactionInfo.HasTransaction property will return // false. We created it only to preserve the integrity of // the ThreadLocal stack maintained in this class. - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Skipping transactional joinpoint [" + joinpointIdentification + "] because no transaction manager has been configured"); @@ -404,7 +405,7 @@ namespace Spring.Transaction.Interceptor { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Completing transaction for [" + transactionInfo.JoinpointIdentification + "]"); } @@ -434,7 +435,7 @@ namespace Spring.Transaction.Interceptor { if ( transactionInfo != null && transactionInfo.HasTransaction ) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Completing transaction for [" + transactionInfo.JoinpointIdentification + "] after exception: " + exception); } diff --git a/src/Spring/Spring.Data/Transaction/Support/AbstractPlatformTransactionManager.cs b/src/Spring/Spring.Data/Transaction/Support/AbstractPlatformTransactionManager.cs index 684eb914..0ff185de 100644 --- a/src/Spring/Spring.Data/Transaction/Support/AbstractPlatformTransactionManager.cs +++ b/src/Spring/Spring.Data/Transaction/Support/AbstractPlatformTransactionManager.cs @@ -20,6 +20,7 @@ using System.Collections; using System.Data; +using Microsoft.Extensions.Logging; namespace Spring.Transaction.Support { @@ -511,7 +512,7 @@ namespace Spring.Transaction.Support public ITransactionStatus GetTransaction(ITransactionDefinition definition) { object transaction = DoGetTransaction(); - bool debugEnabled = log.IsDebugEnabled; + bool debugEnabled = log.IsEnabled(LogLevel.Debug); if (debugEnabled) { diff --git a/src/Spring/Spring.Data/Transaction/Support/TransactionSynchronizationManager.cs b/src/Spring/Spring.Data/Transaction/Support/TransactionSynchronizationManager.cs index 0ec8da68..80a40163 100644 --- a/src/Spring/Spring.Data/Transaction/Support/TransactionSynchronizationManager.cs +++ b/src/Spring/Spring.Data/Transaction/Support/TransactionSynchronizationManager.cs @@ -20,7 +20,7 @@ using System.Collections; using System.Data; - +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Threading; using Spring.Util; @@ -67,7 +67,7 @@ namespace Spring.Transaction.Support { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof (TransactionSynchronizationManager)); + private static readonly ILog LOG = LogManager.GetLogger(typeof (TransactionSynchronizationManager)); #endregion @@ -145,7 +145,7 @@ namespace Spring.Transaction.Support } object val = resources[key]; - if (val != null && LOG.IsDebugEnabled) + if (val != null && LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Retrieved value [" + Describe(val) + "] for key [" + Describe(key) + "] bound to thread [" + SystemUtils.ThreadId + "]"); @@ -176,7 +176,7 @@ namespace Spring.Transaction.Support "] bound to thread [" + SystemUtils.ThreadId + "]"); } resources.Add(key, value); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Bound value [" + Describe(value) + "] for key [" + Describe(key) + "] to thread [" + SystemUtils.ThreadId + "]"); @@ -206,7 +206,7 @@ namespace Spring.Transaction.Support { LogicalThreadContext.FreeNamedDataSlot(resourcesDataSlotName); } - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Removed value [" + Describe(val) + "] for key [" + Describe(key) + "] from thread [" + SystemUtils.ThreadId + "]"); @@ -231,7 +231,7 @@ namespace Spring.Transaction.Support { throw new InvalidOperationException( "Cannot activate transaction synchronization - already active" ); } - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Initializing transaction synchronization"); } @@ -254,7 +254,7 @@ namespace Spring.Transaction.Support { throw new InvalidOperationException( "Cannot deactivate transaction synchronization - not active" ); } - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Clearing transaction synchronization"); } diff --git a/src/Spring/Spring.Data/Transaction/Support/TransactionTemplate.cs b/src/Spring/Spring.Data/Transaction/Support/TransactionTemplate.cs index 7c738145..5aa7db11 100644 --- a/src/Spring/Spring.Data/Transaction/Support/TransactionTemplate.cs +++ b/src/Spring/Spring.Data/Transaction/Support/TransactionTemplate.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; namespace Spring.Transaction.Support @@ -197,7 +198,7 @@ namespace Spring.Transaction.Support /// The thrown application exception or error. private void rollbackOnException( ITransactionStatus status, Exception exception ) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Initiating transaction rollback on application exception", exception); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnection.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnection.cs index d948a4f5..44fea797 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnection.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Common/EmsConnection.cs @@ -18,6 +18,7 @@ #endregion + namespace Spring.Messaging.Ems.Common { /// diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachedSession.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachedSession.cs index e4bcae7c..d1098a3c 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachedSession.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachedSession.cs @@ -19,6 +19,7 @@ #endregion using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Messaging.Ems.Common; using Spring.Collections; using Spring.Util; @@ -92,7 +93,7 @@ namespace Spring.Messaging.Ems.Connections { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Found cached MessageProducer for destination [" + destination + "]"); } @@ -104,7 +105,7 @@ namespace Spring.Messaging.Ems.Connections producer = target.CreateProducer(destination); #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Creating cached MessageProducer for destination [" + destination + "]"); } @@ -176,7 +177,7 @@ namespace Spring.Messaging.Ems.Connections { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Returning cached Session: " + target); } @@ -189,7 +190,7 @@ namespace Spring.Messaging.Ems.Connections private void PhysicalClose() { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Closing cached Session: " + this.target); } @@ -307,7 +308,7 @@ namespace Spring.Messaging.Ems.Connections IMessageConsumer consumer = (IMessageConsumer)cachedConsumers[cacheKey]; if (consumer != null) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Found cached EMS MessageConsumer for destination [" + destination + "]: " + consumer); } @@ -324,7 +325,7 @@ namespace Spring.Messaging.Ems.Connections { consumer = target.CreateConsumer(destination, selector); } - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Creating cached EMS MessageConsumer for destination [" + destination + "]: " + consumer); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachingConnectionFactory.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachingConnectionFactory.cs index 47d52d23..6c07df04 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachingConnectionFactory.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/CachingConnectionFactory.cs @@ -19,8 +19,9 @@ #endregion using System.Collections; - +using Microsoft.Extensions.Logging; using Spring.Messaging.Ems.Common; + using Spring.Collections; using Spring.Util; @@ -186,7 +187,7 @@ namespace Spring.Messaging.Ems.Connections } catch (Exception ex) { - LOG.Trace("Could not close cached EMS Session", ex); + LOG.LogTrace(ex, "Could not close cached EMS Session"); } } } @@ -229,7 +230,7 @@ namespace Spring.Messaging.Ems.Connections } if (session != null) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Found cached Session for mode " + mode + ": " + (session is IDecoratorSession ? ((IDecoratorSession) session).TargetSession : session)); @@ -238,7 +239,7 @@ namespace Spring.Messaging.Ems.Connections else { ISession targetSession = CreateSession(con, mode); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Creating cached Session for mode " + mode + ": " + targetSession); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs index 8f842bb7..3798c5aa 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs @@ -19,6 +19,7 @@ #endregion using System.Data; +using Microsoft.Extensions.Logging; using Spring.Messaging.Ems.Common; using Spring.Messaging.Ems.Core; using Spring.Objects.Factory; @@ -177,7 +178,7 @@ namespace Spring.Messaging.Ems.Connections { con = CreateConnection(); session = CreateSession(con); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { log.Debug("Created EMS transaction on Session [" + session + "] from Connection [" + con + "]"); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs index ed628db5..2c60716d 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/SingleConnectionFactory.cs @@ -19,6 +19,7 @@ #endregion using System.Runtime.Serialization; +using Microsoft.Extensions.Logging; using Spring.Messaging.Ems.Support; using Spring.Messaging.Ems.Core; using Spring.Messaging.Ems.Common; @@ -459,7 +460,7 @@ namespace Spring.Messaging.Ems.Connections } this.target = DoCreateConnection(); PrepareConnection(this.target); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Info("Established shared EMS Connection: " + this.target); } @@ -529,7 +530,7 @@ namespace Spring.Messaging.Ems.Connections /// The connection. protected virtual void CloseConnection(IConnection con) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Closing shared EMS Connection: " + this.target); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Core/EmsTemplate.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Core/EmsTemplate.cs index 946d2a1f..198b4640 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Core/EmsTemplate.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Core/EmsTemplate.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Messaging.Ems.Common; using Spring.Messaging.Ems.Connections; using Spring.Messaging.Ems.Support; @@ -206,7 +207,7 @@ namespace Spring.Messaging.Ems.Core } sessionToUse = sessionToClose; } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Executing callback on EMS Session [" + sessionToUse + "]"); } @@ -526,7 +527,7 @@ namespace Spring.Messaging.Ems.Core { #region Logging - if (logger.IsDebugEnabled) + if (logger.IsDebugEnabled()) { logger.Debug("Found cached MessageProducer for destination [" + destination + "]"); } @@ -539,7 +540,7 @@ namespace Spring.Messaging.Ems.Core emsResources.Producers.Add(destination, producer); #region Logging - if (logger.IsDebugEnabled) + if (logger.IsDebugEnabled()) { logger.Debug("Created cached MessageProducer for destination [" + destination + "]"); } @@ -685,7 +686,7 @@ namespace Spring.Messaging.Ems.Core else { message = messageCreatorDelegate(session); } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Sending created message [" + message + "]"); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLocatorSupport.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLocatorSupport.cs index 21f51cba..9e9da3cb 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLocatorSupport.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLocatorSupport.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Util; @@ -30,7 +31,7 @@ namespace Spring.Messaging.Ems.Jndi protected virtual object Lookup(string jndiName) { object jndiObject = Lookup(jndiName, null); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Located object with JNDI name [" + jndiName + "]"); } @@ -50,7 +51,7 @@ namespace Spring.Messaging.Ems.Jndi jndiName, requiredType, (jndiObject != null ? jndiObject.GetType() : null)); } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Located object with JNDI name [" + jndiName + "]"); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLookupFactoryObject.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLookupFactoryObject.cs index 3cfae4d2..1eda311c 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLookupFactoryObject.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Jndi/JndiLookupFactoryObject.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Core.TypeResolution; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; @@ -129,11 +130,11 @@ namespace Spring.Messaging.Ems.Jndi { if (this.defaultObject != null) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("JNDI lookup failed - returning specified default object instead", ex); } - else if (logger.IsInfoEnabled) + else if (logger.IsEnabled(LogLevel.Information)) { logger.Info("JNDI lookup failed - returning specified default object instead: " + ex); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/AbstractMessageListenerContainer.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/AbstractMessageListenerContainer.cs index 9f131b0e..5f8189eb 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/AbstractMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/AbstractMessageListenerContainer.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Messaging.Ems.Common; using Spring.Messaging.Ems.Core; using Spring.Messaging.Ems.Support; @@ -334,7 +335,7 @@ namespace Spring.Messaging.Ems.Listener if (!AcceptMessagesWhileStopping && !IsRunning) { #region Logging - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("Rejecting received message because of the listener container " + "having been stopped in the meantime: " + message); @@ -412,7 +413,7 @@ namespace Spring.Messaging.Ems.Listener sessionToUse = sessionToClose; } // Actually invoke the message listener - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Invoking listener with message of type [" + message.GetType() + "] and session [" + sessionToUse + "]"); @@ -521,7 +522,7 @@ namespace Spring.Messaging.Ems.Listener if (session.Transacted && IsSessionLocallyTransacted(session)) { // Transacted session created by this container -> rollback - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Initiating transaction rollback on application exception"); } @@ -581,7 +582,7 @@ namespace Spring.Messaging.Ems.Listener { errorHandler.HandleError(exception); } - else if (logger.IsWarnEnabled) + else if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("Execution of EMS message listener failed, and no ErrorHandler has been set.", exception); } diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/Adapter/MessageListenerAdapter.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/Adapter/MessageListenerAdapter.cs index 246dff09..5163beb2 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/Adapter/MessageListenerAdapter.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/Adapter/MessageListenerAdapter.cs @@ -1,4 +1,5 @@ using System.Reflection; +using Microsoft.Extensions.Logging; using Spring.Expressions; using Spring.Messaging.Ems.Common; using Spring.Messaging.Ems.Support; @@ -381,7 +382,7 @@ namespace Spring.Messaging.Ems.Listener.Adapter { if (session != null) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Listener method returned result [" + result + "] - generating response message for it"); @@ -393,7 +394,7 @@ namespace Spring.Messaging.Ems.Listener.Adapter } else { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Listener method returned result [" + result + "]: not generating response message for it because of no EMS Session given"); diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/SimpleMessageListenerContainer.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/SimpleMessageListenerContainer.cs index e148d312..efb6970e 100644 --- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/SimpleMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Listener/SimpleMessageListenerContainer.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Messaging.Ems.Common; using Spring.Messaging.Ems.Support; @@ -194,7 +195,7 @@ namespace Spring.Messaging.Ems.Listener // First invoke the user-specific ExceptionListener, if any. InvokeExceptionListener(exception); // now try to recover the shared Connection and all consumers... - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Trying to recover from EMS Connection exception: " + exception); } @@ -242,7 +243,7 @@ namespace Spring.Messaging.Ems.Listener } catch (Exception ex) { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Could not refresh Connection - retrying in " + recoveryInterval, ex); } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs index 829c6169..a48ca2e6 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs @@ -15,6 +15,7 @@ */ using Apache.NMS; +using Microsoft.Extensions.Logging; using Spring.Messaging.Nms.Support; using Spring.Util; using IQueue=Apache.NMS.IQueue; @@ -86,14 +87,14 @@ namespace Spring.Messaging.Nms.Connections { if (cachedUnspecifiedDestinationMessageProducer != null) { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Found cached MessageProducer for unspecified destination"); } } else { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Creating cached MessageProducer for unspecified destination"); } @@ -128,7 +129,7 @@ namespace Spring.Messaging.Nms.Connections { if (cachedProducers.TryGetValue(destination, out var producer)) { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Found cached MessageProducer for destination [" + destination + "]"); } @@ -137,7 +138,7 @@ namespace Spring.Messaging.Nms.Connections { producer = await target.CreateProducerAsync(destination).Awaiter(); - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Creating cached MessageProducer for destination [" + destination + "]"); } @@ -216,7 +217,7 @@ namespace Spring.Messaging.Nms.Connections // Allow for multiple close calls... if (!sessionList.Contains(this)) { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Returning cached Session: " + target); } @@ -227,7 +228,7 @@ namespace Spring.Messaging.Nms.Connections private async Task PhysicalClose() { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Closing cached Session: " + target); } @@ -447,7 +448,7 @@ namespace Spring.Messaging.Nms.Connections var cacheKey = new ConsumerCacheKey(destination, selector, noLocal, subscriptionName, durable, shared); if (cachedConsumers.TryGetValue(cacheKey, out var consumer)) { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Found cached NMS MessageConsumer for destination [" + destination + "]: " + consumer); } @@ -472,7 +473,7 @@ namespace Spring.Messaging.Nms.Connections } } - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Creating cached NMS MessageConsumer for destination [" + destination + "]: " + consumer); } @@ -939,4 +940,4 @@ namespace Spring.Messaging.Nms.Connections return destination.GetHashCode(); } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachingConnectionFactory.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachingConnectionFactory.cs index 2d4b1c36..b5011f36 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachingConnectionFactory.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachingConnectionFactory.cs @@ -15,6 +15,7 @@ */ using Apache.NMS; +using Microsoft.Extensions.Logging; using Spring.Messaging.Nms.Support; using Spring.Util; @@ -165,7 +166,7 @@ namespace Spring.Messaging.Nms.Connections } catch (Exception ex) { - Log.Trace("Could not close cached NMS Session", ex); + Log.LogTrace(ex, "Could not close cached NMS Session"); } } } @@ -215,7 +216,7 @@ namespace Spring.Messaging.Nms.Connections if (session != null) { - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Found cached Session for mode " + mode + ": " + (session is IDecoratorSession decoratorSession ? decoratorSession.TargetSession : session)); @@ -224,7 +225,7 @@ namespace Spring.Messaging.Nms.Connections else { ISession targetSession = await con.CreateSessionAsync(mode).Awaiter(); - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug("Creating cached Session for mode " + mode + ": " + targetSession); } @@ -248,4 +249,4 @@ namespace Spring.Messaging.Nms.Connections return new CachedSession(targetSession, sessionList, this); } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ConnectionFactoryUtils.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ConnectionFactoryUtils.cs index da09348f..b7ca411a 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ConnectionFactoryUtils.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ConnectionFactoryUtils.cs @@ -486,4 +486,4 @@ namespace Spring.Messaging.Nms.Connections #endregion } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs index 01118dc7..8d5f5cbb 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs @@ -20,6 +20,7 @@ using System.Data; using Apache.NMS; +using Microsoft.Extensions.Logging; using Spring.Messaging.Nms.Core; using Spring.Objects.Factory; using Spring.Transaction; @@ -194,7 +195,7 @@ namespace Spring.Messaging.Nms.Connections { con = CreateConnection(); session = CreateSession(con); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { log.Debug("Created NMS transaction on Session [" + session + "] from Connection [" + con + "]"); } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/SingleConnectionFactory.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/SingleConnectionFactory.cs index b51fbd9f..99db1515 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/SingleConnectionFactory.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/SingleConnectionFactory.cs @@ -19,6 +19,7 @@ #endregion using Apache.NMS; +using Microsoft.Extensions.Logging; using Spring.Messaging.Nms.Core; using Spring.Messaging.Nms.Support; using Spring.Objects.Factory; @@ -373,7 +374,7 @@ namespace Spring.Messaging.Nms.Connections this.target = DoCreateConnection(); PrepareConnection(this.target); - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Info("Established shared NMS Connection: " + this.target); } @@ -449,7 +450,7 @@ namespace Spring.Messaging.Nms.Connections /// The connection. protected virtual void CloseConnection(IConnection con) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Closing shared NMS Connection: " + this.target); } @@ -724,4 +725,4 @@ namespace Spring.Messaging.Nms.Connections return "Shared NMS Connection: " + this.target; } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs index fa4b9cb2..319dce54 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplate.cs @@ -25,6 +25,7 @@ using Spring.Messaging.Nms.Support.Destinations; using Spring.Transaction.Support; using Spring.Util; using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Core { @@ -184,7 +185,7 @@ namespace Spring.Messaging.Nms.Core } sessionToUse = sessionToClose; } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Executing callback on NMS ISession [" + sessionToUse + "]"); } @@ -560,7 +561,7 @@ namespace Spring.Messaging.Nms.Core else { message = messageCreatorDelegate(session); } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Sending created message [" + message + "]"); } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplateAsync.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplateAsync.cs index 7e8a0249..1a68daa3 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplateAsync.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTemplateAsync.cs @@ -23,6 +23,7 @@ using Spring.Messaging.Nms.Support.Destinations; using Spring.Transaction.Support; using Spring.Util; using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Core { @@ -169,7 +170,7 @@ namespace Spring.Messaging.Nms.Core } sessionToUse = sessionToClose; } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Executing callback on NMS ISession [" + sessionToUse + "]"); } @@ -543,7 +544,7 @@ namespace Spring.Messaging.Nms.Core else { message = messageCreatorDelegate(session); } - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Sending created message [" + message + "]"); } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTrace.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTrace.cs index f493e5c2..95e1685c 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTrace.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsTrace.cs @@ -19,6 +19,7 @@ #endregion using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Core { @@ -97,7 +98,7 @@ namespace Spring.Messaging.Nms.Core /// The message. public void Fatal(string message) { - log.Fatal(message); + log.LogCritical(message); } /// @@ -108,7 +109,7 @@ namespace Spring.Messaging.Nms.Core /// public bool IsDebugEnabled { - get { return log.IsDebugEnabled; } + get { return log.IsEnabled(LogLevel.Debug); } } /// @@ -119,7 +120,7 @@ namespace Spring.Messaging.Nms.Core /// public bool IsInfoEnabled { - get { return log.IsInfoEnabled; } + get { return log.IsEnabled(LogLevel.Information); } } /// @@ -130,7 +131,7 @@ namespace Spring.Messaging.Nms.Core /// public bool IsWarnEnabled { - get { return log.IsWarnEnabled; } + get { return log.IsEnabled(LogLevel.Warning); } } /// @@ -141,7 +142,7 @@ namespace Spring.Messaging.Nms.Core /// public bool IsErrorEnabled { - get { return log.IsErrorEnabled; } + get { return log.IsEnabled(LogLevel.Error); } } /// @@ -152,8 +153,8 @@ namespace Spring.Messaging.Nms.Core /// public bool IsFatalEnabled { - get { return log.IsFatalEnabled; } + get { return log.IsEnabled(LogLevel.Critical); } } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs index 5c4d6a18..134043e6 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs @@ -22,6 +22,7 @@ using Spring.Messaging.Nms.Core; using Spring.Messaging.Nms.Support; using Spring.Util; using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Listener { @@ -338,7 +339,7 @@ namespace Spring.Messaging.Nms.Listener if (!AcceptMessagesWhileStopping && !IsRunning) { #region Logging - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("Rejecting received message because of the listener container " + "having been stopped in the meantime: " + message); @@ -415,7 +416,7 @@ namespace Spring.Messaging.Nms.Listener sessionToUse = sessionToClose; } // Actually invoke the message listener - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Invoking listener with message of type [" + message.GetType() + "] and session [" + sessionToUse + "]"); @@ -524,7 +525,7 @@ namespace Spring.Messaging.Nms.Listener if (session.Transacted && IsSessionLocallyTransacted(session)) { // Transacted session created by this container -> rollback - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Initiating transaction rollback on application exception"); } @@ -588,7 +589,7 @@ namespace Spring.Messaging.Nms.Listener { errorHandler.HandleError(exception); } - else if(logger.IsWarnEnabled) + else if(logger.IsEnabled(LogLevel.Warning)) { logger.Warn("Execution of NMS message listener failed, and no ErrorHandler has been set.", exception); } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs index 1ef381b0..66ef7f58 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs @@ -26,6 +26,7 @@ using Spring.Messaging.Nms.Support.Converter; using Spring.Messaging.Nms.Support.Destinations; using Spring.Util; using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Listener.Adapter { @@ -403,7 +404,7 @@ namespace Spring.Messaging.Nms.Listener.Adapter { if (session != null) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Listener method returned result [" + result + "] - generating response message for it"); @@ -415,7 +416,7 @@ namespace Spring.Messaging.Nms.Listener.Adapter } else { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Listener method returned result [" + result + "]: not generating response message for it because of no NMS ISession given"); diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs index c0b54f38..252d68e4 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs @@ -22,6 +22,7 @@ using Spring.Collections; using Spring.Messaging.Nms.Core; using Spring.Messaging.Nms.Support; using Apache.NMS; +using Microsoft.Extensions.Logging; using Spring.Transaction.Support; using Spring.Util; @@ -192,7 +193,7 @@ namespace Spring.Messaging.Nms.Listener // First invoke the user-specific ExceptionListener, if any. InvokeExceptionListener(exception); // now try to recover the shared Connection and all consumers... - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Trying to recover from NMS Connection exception: " + exception); } @@ -239,9 +240,9 @@ namespace Spring.Messaging.Nms.Listener break; } catch (Exception ex) { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { - logger.Info("Could not refresh Connection - retrying in " + recoveryInterval, ex); + logger.LogInformation(ex, "Could not refresh Connection - retrying in {RecoveryInterval}", recoveryInterval); } } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessor.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessor.cs index ff4827d5..1b8096be 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessor.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessor.cs @@ -21,6 +21,7 @@ using Spring.Messaging.Nms.Core; using Spring.Objects.Factory; using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Support { @@ -135,7 +136,7 @@ namespace Spring.Messaging.Nms.Support } if (Tracer.Trace == null) { - if (logger.IsTraceEnabled) + if (logger.IsEnabled(LogLevel.Trace)) { logger.Trace("Setting Apache.NMS.Tracer.Trace to default implementation that directs output to Common.Logging"); } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessorAsync.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessorAsync.cs index 8024d4e1..74b7c015 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessorAsync.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/NmsAccessorAsync.cs @@ -19,6 +19,7 @@ using Spring.Messaging.Nms.Core; using Spring.Objects.Factory; using Apache.NMS; +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Nms.Support { @@ -128,7 +129,7 @@ namespace Spring.Messaging.Nms.Support } if (Tracer.Trace == null) { - if (logger.IsTraceEnabled) + if (logger.IsEnabled(LogLevel.Trace)) { logger.Trace("Setting Apache.NMS.Tracer.Trace to default implementation that directs output to Common.Logging"); } diff --git a/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs b/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs index 517c3067..21f7cd66 100644 --- a/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs +++ b/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs @@ -42,7 +42,7 @@ namespace Spring.Messaging.Core public class DefaultMessageQueueFactory : IMessageQueueFactory, IApplicationContextAware { /// - /// The instance for this class. + /// The instance for this class. /// private readonly ILog log = LogManager.GetLogger(typeof(DefaultMessageQueueFactory)); diff --git a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs index 22d9014f..3f291267 100644 --- a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs +++ b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs @@ -1,4 +1,5 @@ using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Messaging.Support; using Spring.Objects.Factory; @@ -68,7 +69,7 @@ namespace Spring.Messaging.Core } else { #region Logging - if (LOG.IsWarnEnabled) + if (LOG.IsEnabled(LogLevel.Warning)) { LOG.Warn( "Path for MessageQueueFactoryObject named [" + diff --git a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTemplate.cs b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTemplate.cs index 8e65b80a..a0904c2b 100644 --- a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTemplate.cs +++ b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTemplate.cs @@ -18,11 +18,13 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Messaging.Support.Converters; using Spring.Objects.Factory; using Spring.Util; + #if NETSTANDARD using Experimental.System.Messaging; #else @@ -322,7 +324,7 @@ namespace Spring.Messaging.Core { #region Logging - if (LOG.IsWarnEnabled) + if (LOG.IsEnabled(LogLevel.Warning)) { LOG.Warn( "The ApplicationContext property has not been set, so the MessageQueueMetadataCache can not be automatically generated. " + @@ -568,7 +570,7 @@ namespace Spring.Messaging.Core } } else { - if (LOG.IsWarnEnabled) + if (LOG.IsEnabled(LogLevel.Warning)) { LOG.Warn("MetadataCache has not been initialized. Set the MetadataCache explicitly in standalone usage and/or " + "configure the MessageQueueTemplate in an ApplicationContext. If deployed in an ApplicationContext by default " + @@ -598,7 +600,7 @@ namespace Spring.Messaging.Core { if (transactionToUse != null) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug( "Sending messsage using externally managed MessageQueueTransction to transactional queue with path [" + mq.Path + "]."); @@ -634,7 +636,7 @@ namespace Spring.Messaging.Core } else { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Sending messsage without MSMQ transaction to non-transactional queue with path [" + mq.Path + "]."); } diff --git a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTransactionManager.cs b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTransactionManager.cs index 24a1c6f2..b235fbae 100644 --- a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTransactionManager.cs +++ b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueTransactionManager.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Data.Core; using Spring.Transaction; using Spring.Transaction.Support; @@ -182,7 +183,7 @@ namespace Spring.Messaging.Core MessageQueueTransaction transaction = txObject.ResourceHolder.MessageQueueTransaction; try { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Committing MessageQueueTransaction"); } @@ -207,7 +208,7 @@ namespace Spring.Messaging.Core MessageQueueTransaction transaction = txObject.ResourceHolder.MessageQueueTransaction; try { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Committing MessageQueueTransaction"); } @@ -279,4 +280,4 @@ namespace Spring.Messaging.Core #endregion } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/AbstractMessageListenerContainer.cs b/src/Spring/Spring.Messaging/Messaging/Listener/AbstractMessageListenerContainer.cs index bb9a83ff..29c2e401 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/AbstractMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/AbstractMessageListenerContainer.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Messaging.Core; using Spring.Messaging.Support.Converters; @@ -192,7 +193,7 @@ namespace Spring.Messaging.Listener { if (!Running) { - if (LOG.IsWarnEnabled) + if (LOG.IsEnabled(LogLevel.Warning)) { LOG.Warn("Not processing recieved message because of the listener container " + "having been stopped in the meantime: " + message); diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/AbstractPeekingMessageListenerContainer.cs b/src/Spring/Spring.Messaging/Messaging/Listener/AbstractPeekingMessageListenerContainer.cs index 8b786b57..a8865fef 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/AbstractPeekingMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/AbstractPeekingMessageListenerContainer.cs @@ -18,6 +18,7 @@ #endregion + #if NETSTANDARD using Experimental.System.Messaging; #else diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/DistributedTxMessageListenerContainer.cs b/src/Spring/Spring.Messaging/Messaging/Listener/DistributedTxMessageListenerContainer.cs index 3d8e50dd..485858d4 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/DistributedTxMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/DistributedTxMessageListenerContainer.cs @@ -19,6 +19,7 @@ #endregion using System.Transactions; +using Microsoft.Extensions.Logging; using Spring.Transaction; #if NETSTANDARD @@ -101,7 +102,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DoReceiveAndExecuteUsingTxScopeTransactionManager"); } @@ -125,7 +126,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace( "MessageQueueErrorCode.IOTimeout: No message available to receive. May have been processed by another thread."); @@ -152,7 +153,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Message recieved is null from Queue = [" + mq.Path + "]"); } @@ -168,7 +169,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Received message [" + message.Id + "] on queue [" + mq.Path + "]"); } diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs b/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs index df987f87..5a72235d 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Expressions; using Spring.Messaging.Core; @@ -503,7 +504,7 @@ namespace Spring.Messaging.Listener /// The original request. protected virtual void HandleResult(object result, Message request) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Listener method returned result [" + result + "] - generating response message for it"); @@ -522,7 +523,7 @@ namespace Spring.Messaging.Listener protected virtual void SendResponse(MessageQueue destination, Message response) { //Will send with appropriate transaction semantics - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Sending response message to path = [" + destination.Path + "]"); } diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/NonTransactionalMessageListenerContainer.cs b/src/Spring/Spring.Messaging/Messaging/Listener/NonTransactionalMessageListenerContainer.cs index 4b09ebc6..747165d3 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/NonTransactionalMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/NonTransactionalMessageListenerContainer.cs @@ -18,11 +18,13 @@ #endregion + #if NETSTANDARD using Experimental.System.Messaging; #else using System.Messaging; #endif +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Listener { @@ -86,7 +88,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Receiving message with zero timeout for queue = [" + mq.Path + "]"); } @@ -103,7 +105,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace( "MessageQueueErrorCode.IOTimeout: No message available to receive. May have been processed by another thread."); @@ -119,7 +121,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsErrorEnabled) + if (LOG.IsEnabled(LogLevel.Error)) { LOG.Error("Error receiving message from MessageQueue [" + mq.Path + "], closing queue and clearing connection cache."); @@ -140,7 +142,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Message recieved is null from Queue = [" + mq.Path + "]"); } @@ -154,7 +156,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Received message [" + message.Id + "] on queue [" + mq.Path + "]"); } diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueDistributedTransactionExceptionHandler.cs b/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueDistributedTransactionExceptionHandler.cs index a0454451..63e905d8 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueDistributedTransactionExceptionHandler.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueDistributedTransactionExceptionHandler.cs @@ -18,11 +18,13 @@ #endregion + #if NETSTANDARD using Experimental.System.Messaging; #else using System.Messaging; #endif +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Listener { @@ -125,7 +127,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsInfoEnabled) + if (LOG.IsEnabled(LogLevel.Information)) { LOG.Info("Sending message with id = [" + message.Id + "] to queue [" + mq.Path + "]."); } @@ -138,7 +140,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsErrorEnabled) + if (LOG.IsEnabled(LogLevel.Error)) { LOG.Error("Could not send message with id = [" + message.Id + "] to queue [" + mq.Path + "].", e); LOG.Error("Message will not be processed. Message Body = " + message.Body); diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueExceptionHandler.cs b/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueExceptionHandler.cs index b1cccca8..4c74d2c0 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueExceptionHandler.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/SendToQueueExceptionHandler.cs @@ -18,12 +18,13 @@ #endregion + #if NETSTANDARD using Experimental.System.Messaging; #else using System.Messaging; #endif - +using Microsoft.Extensions.Logging; namespace Spring.Messaging.Listener { @@ -155,7 +156,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsInfoEnabled) + if (LOG.IsEnabled(LogLevel.Information)) { LOG.Info("Sending message with id = [" + message.Id + "] to queue [" + mq.Path + "]."); } @@ -169,7 +170,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsErrorEnabled) + if (LOG.IsEnabled(LogLevel.Error)) { LOG.Error("Could not send message with id = [" + message.Id + "] to queue [" + mq.Path + "].",e); LOG.Error("Message will not be processed. Message Body = " + message.Body); diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/TransactionalMessageListenerContainer.cs b/src/Spring/Spring.Messaging/Messaging/Listener/TransactionalMessageListenerContainer.cs index dbcf5930..2f257a0c 100644 --- a/src/Spring/Spring.Messaging/Messaging/Listener/TransactionalMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging/Messaging/Listener/TransactionalMessageListenerContainer.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Data.Core; using Spring.Messaging.Core; using Spring.Transaction; @@ -294,7 +295,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DoRecieveAndExecuteUsingMessageQueueTransactionManager"); } @@ -314,7 +315,7 @@ namespace Spring.Messaging.Listener if (ex.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout) { //expected to occur occasionally - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("IOTimeout: Message to receive was already processed by another thread."); } @@ -327,7 +328,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsErrorEnabled) + if (LOG.IsEnabled(LogLevel.Error)) { LOG.Error("Error receiving message from DefaultMessageQueue [" + mq.Path + "], closing queue and clearing connection cache."); @@ -350,7 +351,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Message recieved is null from Queue = [" + mq.Path + "]"); } @@ -365,7 +366,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Received message [" + message.Id + "] on queue [" + mq.Path + "]"); } @@ -377,7 +378,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("MessageListener executed"); } @@ -394,7 +395,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug( "Exception handler's TransactionAction has rolled back MessageQueueTransaction for queue [" + @@ -429,7 +430,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Executing DoRecieveAndExecuteUsingResourceTransactionManagerWithTxQueue"); } @@ -442,7 +443,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Started MessageQueueTransaction for queue = [" + mq.Path + "]"); } @@ -457,7 +458,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Receiving message with zero timeout for queue = [" + mq.Path + "]"); } @@ -474,7 +475,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace( "MessageQueueErrorCode.IOTimeout: No message available to receive. May have been processed by another thread."); @@ -491,7 +492,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsErrorEnabled) + if (LOG.IsEnabled(LogLevel.Error)) { LOG.Error("Error receiving message from DefaultMessageQueue [" + mq.Path + "], closing queue and clearing connection cache."); @@ -514,7 +515,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Message recieved is null from Queue = [" + mq.Path + "]"); } @@ -529,7 +530,7 @@ namespace Spring.Messaging.Listener { #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Received message [" + message.Id + "] on queue [" + mq.Path + "]"); } @@ -549,7 +550,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("MessageListener executed"); } @@ -560,7 +561,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsTraceEnabled) + if (LOG.IsEnabled(LogLevel.Trace)) { LOG.Trace("Committed MessageQueueTransaction for queue [" + mq.Path + "]"); } @@ -577,7 +578,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug( "Exception handler's TransactionAction has rolled back MessageQueueTransaction for queue [" + @@ -593,7 +594,7 @@ namespace Spring.Messaging.Listener #region Logging - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug( "Exception handler's TransactionAction has committed MessageQueueTransaction for queue [" + diff --git a/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerAccessor.cs b/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerAccessor.cs index 92d06faf..62fe2cd6 100644 --- a/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerAccessor.cs +++ b/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerAccessor.cs @@ -373,10 +373,9 @@ namespace Spring.Scheduling.Quartz } catch (ObjectAlreadyExistsException ex) { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { - logger.Debug( - $"Unexpectedly found existing trigger, assumably due to cluster race condition: {ex.Message} - can safely be ignored"); + logger.Debug($"Unexpectedly found existing trigger, assumably due to cluster race condition: {ex.Message} - can safely be ignored"); } if (overwriteExistingJobs) diff --git a/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerFactoryObject.cs b/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerFactoryObject.cs index 70eceaeb..c1005bbe 100644 --- a/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerFactoryObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz3/Scheduling/Quartz/SchedulerFactoryObject.cs @@ -16,6 +16,7 @@ using System.Collections; using System.Collections.Specialized; +using Microsoft.Extensions.Logging; using Quartz; using Quartz.Impl; using Quartz.Simpl; @@ -628,7 +629,7 @@ namespace Spring.Scheduling.Quartz if (configLocation != null) { - if (Logger.IsInfoEnabled) + if (Logger.IsEnabled(LogLevel.Information)) { Logger.Info("Loading Quartz config from [" + configLocation + "]"); } @@ -765,10 +766,9 @@ namespace Spring.Scheduling.Quartz } else { - if (Logger.IsInfoEnabled) + if (Logger.IsEnabled(LogLevel.Information)) { - Logger.InfoFormat("Will start Quartz Scheduler [{0}] in {1} seconds", sched.SchedulerName, - startDelay); + Logger.LogInformation("Will start Quartz Scheduler [{SchedulerName}] in {StartDelaySeconds} seconds", sched.SchedulerName, startDelay); } await sched.StartDelayed(startDelay).ConfigureAwait(false); diff --git a/src/Spring/Spring.Services/Remoting/CaoExporter.cs b/src/Spring/Spring.Services/Remoting/CaoExporter.cs index 72ac3e64..2487f0b6 100644 --- a/src/Spring/Spring.Services/Remoting/CaoExporter.cs +++ b/src/Spring/Spring.Services/Remoting/CaoExporter.cs @@ -19,7 +19,7 @@ #endregion using System.Runtime.Remoting; - +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Objects.Factory; using Spring.Objects.Factory.Support; @@ -38,7 +38,7 @@ namespace Spring.Remoting { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(CaoExporter)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(CaoExporter)); #endregion @@ -183,7 +183,7 @@ namespace Spring.Remoting #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug(String.Format("Target '{0}' registered.", targetName)); } diff --git a/src/Spring/Spring.Services/Remoting/CaoFactoryObject.cs b/src/Spring/Spring.Services/Remoting/CaoFactoryObject.cs index 3c5b9747..d3f28483 100644 --- a/src/Spring/Spring.Services/Remoting/CaoFactoryObject.cs +++ b/src/Spring/Spring.Services/Remoting/CaoFactoryObject.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Remoting.Support; @@ -34,7 +35,7 @@ namespace Spring.Remoting { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(CaoFactoryObject)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(CaoFactoryObject)); #endregion @@ -134,7 +135,7 @@ namespace Spring.Remoting public object GetObject() { string url = serviceUrl.TrimEnd('/') + '/' + remoteTargetName; - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug("Accessing CAO object of type ICaoRemoteFactory object at url = [" + url + "]"); } diff --git a/src/Spring/Spring.Services/Remoting/RemotingConfigurer.cs b/src/Spring/Spring.Services/Remoting/RemotingConfigurer.cs index 6a4cba26..06ddf1d9 100644 --- a/src/Spring/Spring.Services/Remoting/RemotingConfigurer.cs +++ b/src/Spring/Spring.Services/Remoting/RemotingConfigurer.cs @@ -19,6 +19,7 @@ #endregion using System.Runtime.Remoting; +using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Core.IO; using Spring.Objects.Factory.Config; @@ -119,7 +120,7 @@ namespace Spring.Remoting #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { if (filename == null) { diff --git a/src/Spring/Spring.Services/Remoting/SaoExporter.cs b/src/Spring/Spring.Services/Remoting/SaoExporter.cs index af05fabf..4950c3ec 100644 --- a/src/Spring/Spring.Services/Remoting/SaoExporter.cs +++ b/src/Spring/Spring.Services/Remoting/SaoExporter.cs @@ -22,6 +22,7 @@ using System.Collections; using System.Reflection; using System.Reflection.Emit; using System.Runtime.Remoting; +using Microsoft.Extensions.Logging; using Spring.Core.TypeResolution; using Spring.Proxy; using Spring.Objects.Factory; @@ -47,7 +48,7 @@ namespace Spring.Remoting { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger( typeof( SaoExporter ) ); + private static readonly ILog LOG = LogManager.GetLogger( typeof( SaoExporter ) ); #endregion @@ -276,7 +277,7 @@ namespace Spring.Remoting #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { LOG.Debug( String.Format( "Target '{0}' exported as '{1}'.", targetName, objectUri ) ); } diff --git a/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs b/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs index 38a83f0f..e095b624 100644 --- a/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs +++ b/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs @@ -19,7 +19,7 @@ #endregion using System.ServiceModel; - +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; namespace Spring.ServiceModel.Activation @@ -33,7 +33,7 @@ namespace Spring.ServiceModel.Activation { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(ServiceHostFactoryObject)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(ServiceHostFactoryObject)); #endregion @@ -183,7 +183,7 @@ namespace Spring.ServiceModel.Activation #region Instrumentation - if (LOG.IsInfoEnabled) + if (LOG.IsEnabled(LogLevel.Information)) { LOG.Info(String.Format("The service '{0}' is ready and can now be accessed.", TargetName)); } diff --git a/src/Spring/Spring.Services/ServiceModel/ChannelFactoryObject.cs b/src/Spring/Spring.Services/ServiceModel/ChannelFactoryObject.cs index ddbf6c1f..72187876 100644 --- a/src/Spring/Spring.Services/ServiceModel/ChannelFactoryObject.cs +++ b/src/Spring/Spring.Services/ServiceModel/ChannelFactoryObject.cs @@ -19,7 +19,7 @@ #endregion using System.ServiceModel; - +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; namespace Spring.ServiceModel @@ -34,7 +34,7 @@ namespace Spring.ServiceModel { #region Logging - private static readonly Common.Logging.ILog Log = Common.Logging.LogManager.GetLogger(typeof(ChannelFactoryObject<>)); + private static readonly ILog Log = LogManager.GetLogger(typeof(ChannelFactoryObject<>)); #endregion @@ -75,7 +75,7 @@ namespace Spring.ServiceModel { #region Instrumentation - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug(String.Format( "Creating channel of type '{0}' for the specified endpoint '{1}'...", diff --git a/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs b/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs index 63f630d5..b0641dab 100644 --- a/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs +++ b/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs @@ -41,7 +41,7 @@ namespace Spring.ServiceModel { #region Logging - //private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(ServiceExporter)); + //private static readonly ILog LOG = LogManager.GetLogger(typeof(ServiceExporter)); #endregion diff --git a/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs b/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs index 915e5198..cbb2e13b 100644 --- a/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs +++ b/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs @@ -28,6 +28,7 @@ using System.Web.Services; using System.Web.Services.Description; using System.Web.Services.Protocols; using System.Web.Services.Discovery; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; using Spring.Proxy; @@ -55,7 +56,7 @@ namespace Spring.Web.Services { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(WebServiceProxyFactory)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(WebServiceProxyFactory)); #endregion @@ -323,7 +324,7 @@ namespace Spring.Web.Services #region Instrumentation - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) { if (ServiceUri != null) { @@ -430,7 +431,7 @@ namespace Spring.Web.Services { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(SoapHttpClientProxyTypeBuilder)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(SoapHttpClientProxyTypeBuilder)); #endregion @@ -735,7 +736,7 @@ namespace Spring.Web.Services { #region Instrumentation - if (LOG.IsInfoEnabled) + if (LOG.IsEnabled(LogLevel.Information)) { LOG.Info(String.Format("The binding '{0}', found in the WSDL document located at '{1}', will be use.", binding.Name, this.serviceUri.Description)); } diff --git a/src/Spring/Spring.Template.Velocity.Castle/Template/Velocity/SpringResourceLoader.cs b/src/Spring/Spring.Template.Velocity.Castle/Template/Velocity/SpringResourceLoader.cs index 1950961d..093ba84d 100644 --- a/src/Spring/Spring.Template.Velocity.Castle/Template/Velocity/SpringResourceLoader.cs +++ b/src/Spring/Spring.Template.Velocity.Castle/Template/Velocity/SpringResourceLoader.cs @@ -19,6 +19,7 @@ #endregion using Commons.Collections; +using Microsoft.Extensions.Logging; using NVelocity.Runtime.Resource; using NVelocity.Runtime.Resource.Loader; using Spring.Core.IO; @@ -110,7 +111,7 @@ namespace Spring.Template.Velocity resourceLoaderPaths[i] = path + "/"; } } - if (log.IsInfoEnabled) + if (log.IsEnabled(LogLevel.Information)) { log.Info(string.Format("SpringResourceLoader for Velocity: using resource loader [{0}] and resource loader paths {1}", resourceLoader, resourceLoaderPaths)); } @@ -123,7 +124,7 @@ namespace Spring.Template.Velocity /// a System.IO.Stream representation of the resource public override Stream GetResourceStream(string source) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Looking for Velocity resource with name [{0}]", source)); } @@ -137,7 +138,7 @@ namespace Spring.Template.Velocity } catch (IOException ex) { - if (log.IsErrorEnabled) + if (log.IsEnabled(LogLevel.Error)) { log.Error(string.Format("Could not find Velocity resource: {0}", resource), ex); } diff --git a/src/Spring/Spring.Template.Velocity/Template/Velocity/SpringResourceLoader.cs b/src/Spring/Spring.Template.Velocity/Template/Velocity/SpringResourceLoader.cs index cc740588..ee3d8488 100644 --- a/src/Spring/Spring.Template.Velocity/Template/Velocity/SpringResourceLoader.cs +++ b/src/Spring/Spring.Template.Velocity/Template/Velocity/SpringResourceLoader.cs @@ -19,6 +19,7 @@ #endregion using Commons.Collections; +using Microsoft.Extensions.Logging; using NVelocity.Runtime.Resource; using NVelocity.Runtime.Resource.Loader; using Spring.Core.IO; @@ -103,7 +104,7 @@ namespace Spring.Template.Velocity { resourceLoaderPaths[i] = path + "/"; } } - if (log.IsInfoEnabled) { + if (log.IsEnabled(LogLevel.Information)) { log.Info(string.Format("SpringResourceLoader for Velocity: using resource loader [{0}] and resource loader paths {1}", resourceLoader, resourceLoaderPaths)); } } @@ -114,7 +115,7 @@ namespace Spring.Template.Velocity { /// the source template name /// a System.IO.Stream representation of the resource public override Stream GetResourceStream(string source) { - if (log.IsDebugEnabled) { + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Looking for Velocity resource with name [{0}]", source)); } @@ -123,7 +124,7 @@ namespace Spring.Template.Velocity { try { return resource.InputStream; } catch (IOException ex) { - if (log.IsErrorEnabled) { + if (log.IsEnabled(LogLevel.Error)) { log.Error(string.Format("Could not find Velocity resource: {0}", resource), ex); } } diff --git a/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs b/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs index aac72967..9a4e6088 100644 --- a/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs +++ b/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs @@ -20,6 +20,7 @@ using System.Collections; using Commons.Collections; +using Microsoft.Extensions.Logging; using NVelocity.App; using NVelocity.Exception; using NVelocity.Runtime; @@ -203,7 +204,7 @@ namespace Spring.Template.Velocity { // Load config file if set. if (configLocation != null) { - if (log.IsInfoEnabled) { + if (log.IsEnabled(LogLevel.Information)) { log.Info(string.Format("Loading Velocity config from [{0}]", configLocation)); } FillProperties(extendedProperties, configLocation, false); @@ -303,7 +304,7 @@ namespace Spring.Template.Velocity { extendedProperties.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, StringUtils.CollectionToCommaDelimitedString(resolvedPaths)); } catch (IOException ex) { - if (log.IsDebugEnabled) { + if (log.IsEnabled(LogLevel.Debug)) { log.Error(string.Format("Cannot resolve resource loader path [{0}] to [File]: using SpringResourceLoader", StringUtils.CollectionToCommaDelimitedString(resolvedPaths)), ex); } @@ -312,7 +313,7 @@ namespace Spring.Template.Velocity { } } else { // Always load via SpringResourceLoader (without hot detection of template changes). - if (log.IsDebugEnabled) { + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("File system access not preferred: using SpringResourceLoader"); } InitSpringResourceLoader(velocityEngine, extendedProperties, StringUtils.CollectionToCommaDelimitedString(paths)); diff --git a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs index 1d5a78cc..909f7a0b 100644 --- a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs +++ b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs @@ -19,7 +19,7 @@ #endregion using System.Reflection; - +using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using Spring.Context; @@ -235,7 +235,7 @@ namespace Spring.Testing.Microsoft { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Found " + fields.Length + " fields on " + type); } @@ -243,7 +243,7 @@ namespace Spring.Testing.Microsoft for (int i = 0; i < fields.Length; i++) { FieldInfo field = fields[i]; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Candidate field: " + field); } @@ -253,14 +253,14 @@ namespace Spring.Testing.Microsoft if (oldValue == null) { managedVarNames.Add(field.Name); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Added managed variable '" + field.Name + "'"); } } else { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Rejected managed variable '" + field.Name + "'"); } @@ -295,14 +295,14 @@ namespace Spring.Testing.Microsoft BeforeProtectedVariableInjection(field); obj = this.applicationContext.GetObject(fieldName, field.FieldType); field.SetValue(this, obj); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Populated field: " + field); } } else { - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("No field with name '" + fieldName + "'"); } @@ -310,7 +310,7 @@ namespace Spring.Testing.Microsoft } catch (NoSuchObjectDefinitionException) { - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("No object definition with name '" + fieldName + "'"); } diff --git a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs index 8c06ed7c..875c9951 100644 --- a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs +++ b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs @@ -19,6 +19,7 @@ #endregion using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; using Spring.Util; @@ -212,7 +213,7 @@ namespace Spring.Testing.Microsoft /// Resources to load object definitions from. protected virtual IConfigurableApplicationContext LoadContextLocations(string[] locations) { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Loading config for: " + StringUtils.CollectionToCommaDelimitedString(locations)); } diff --git a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalDbProviderSpringContextTests.cs b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalDbProviderSpringContextTests.cs index 090c338e..2e082534 100644 --- a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalDbProviderSpringContextTests.cs +++ b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalDbProviderSpringContextTests.cs @@ -19,6 +19,7 @@ #endregion using System.Data; +using Microsoft.Extensions.Logging; using Spring.Data.Common; using Spring.Data.Core; @@ -103,7 +104,7 @@ namespace Spring.Testing.Microsoft for (int i = 0; i < names.Length; i++) { int rowCount = this.adoTemplate.ExecuteNonQuery(CommandType.Text, "DELETE FROM " + names[i]); - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Deleted " + rowCount + " rows from table " + names[i]); } diff --git a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalSpringContextTests.cs b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalSpringContextTests.cs index bb035851..570b1d45 100644 --- a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalSpringContextTests.cs +++ b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractTransactionalSpringContextTests.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Transaction; using Spring.Transaction.Support; @@ -304,7 +305,7 @@ namespace Spring.Testing.Microsoft ++this.transactionsStarted; this.complete = !this.defaultRollback; - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Began transaction (" + this.transactionsStarted + "): transaction manager [" + this.transactionManager + "]; default rollback = " + this.defaultRollback); diff --git a/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs b/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs index 4f1d7584..d45af0d8 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs @@ -21,6 +21,8 @@ using System.Data; using System.Reflection; using System.Text.RegularExpressions; + + using Spring.Core.IO; using Spring.Dao; using Spring.Data; diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs index d1781238..fccce6f0 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs @@ -19,7 +19,7 @@ #endregion using System.Reflection; - +using Microsoft.Extensions.Logging; using NUnit.Framework; using Spring.Context; @@ -235,7 +235,7 @@ namespace Spring.Testing.NUnit { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Found " + fields.Length + " fields on " + type); } @@ -243,7 +243,7 @@ namespace Spring.Testing.NUnit for (int i = 0; i < fields.Length; i++) { FieldInfo field = fields[i]; - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Candidate field: " + field); } @@ -253,14 +253,14 @@ namespace Spring.Testing.NUnit if (oldValue == null) { managedVarNames.Add(field.Name); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Added managed variable '" + field.Name + "'"); } } else { - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Rejected managed variable '" + field.Name + "'"); } @@ -295,14 +295,14 @@ namespace Spring.Testing.NUnit BeforeProtectedVariableInjection(field); obj = this.applicationContext.GetObject(fieldName, field.FieldType); field.SetValue(this, obj); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Populated field: " + field); } } else { - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("No field with name '" + fieldName + "'"); } @@ -310,7 +310,7 @@ namespace Spring.Testing.NUnit } catch (NoSuchObjectDefinitionException) { - if (logger.IsWarnEnabled) + if (logger.IsEnabled(LogLevel.Warning)) { logger.Warn("No object definition with name '" + fieldName + "'"); } diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs index 64febe1a..154e1f8c 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs @@ -15,6 +15,7 @@ */ using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; using Spring.Util; @@ -224,7 +225,7 @@ namespace Spring.Testing.NUnit /// Resources to load object definitions from. protected virtual IConfigurableApplicationContext LoadContextLocations(string[] locations) { - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Loading config for: " + StringUtils.CollectionToCommaDelimitedString(locations)); } diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalDbProviderSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalDbProviderSpringContextTests.cs index 99068940..6ac329be 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalDbProviderSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalDbProviderSpringContextTests.cs @@ -1,4 +1,5 @@ using System.Data; +using Microsoft.Extensions.Logging; using Spring.Data.Common; using Spring.Data.Core; using Spring.Testing.Ado; @@ -84,7 +85,7 @@ namespace Spring.Testing.NUnit for (int i = 0; i < names.Length; i++) { int rowCount = this.adoTemplate.ExecuteNonQuery(CommandType.Text, "DELETE FROM " + names[i]); - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Deleted " + rowCount + " rows from table " + names[i]); } diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalSpringContextTests.cs index 8942abfa..13b0003d 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractTransactionalSpringContextTests.cs @@ -1,3 +1,4 @@ +using Microsoft.Extensions.Logging; using Spring.Transaction; using Spring.Transaction.Support; @@ -276,7 +277,7 @@ namespace Spring.Testing.NUnit ++this.transactionsStarted; this.complete = !this.defaultRollback; - if (logger.IsInfoEnabled) + if (logger.IsEnabled(LogLevel.Information)) { logger.Info("Began transaction (" + this.transactionsStarted + "): transaction manager [" + this.transactionManager + "]; default rollback = " + this.defaultRollback); diff --git a/src/Spring/Spring.Web.Conversation.NHibernate5/Data/NHibernate/Support/SessionPerConversationScope.cs b/src/Spring/Spring.Web.Conversation.NHibernate5/Data/NHibernate/Support/SessionPerConversationScope.cs index b058ee15..842f58ae 100644 --- a/src/Spring/Spring.Web.Conversation.NHibernate5/Data/NHibernate/Support/SessionPerConversationScope.cs +++ b/src/Spring/Spring.Web.Conversation.NHibernate5/Data/NHibernate/Support/SessionPerConversationScope.cs @@ -15,12 +15,14 @@ */ using System.Reflection; + using NHibernate; using Spring.Threading; using Spring.Transaction.Support; using Spring.Util; using System.Data; using System.Data.Common; +using Microsoft.Extensions.Logging; using Spring.Web.Conversation; namespace Spring.Data.NHibernate.Support @@ -172,7 +174,7 @@ namespace Spring.Data.NHibernate.Support /// public void Open(IConversationState activeConversation, ICollection allManagedConversation) { - bool isDebugEnabled = log.IsDebugEnabled; + bool isDebugEnabled = log.IsEnabled(LogLevel.Debug); if (IsOpen) { @@ -247,7 +249,7 @@ namespace Spring.Data.NHibernate.Support /// public void Close(ISessionFactory sessionFactory, ICollection allManagedConversation) { - bool isDebugEnabled = log.IsDebugEnabled; + bool isDebugEnabled = log.IsEnabled(LogLevel.Debug); if (isDebugEnabled) log.Debug("Trying to close SessionPerConversationScope"); if (IsOpen) @@ -322,13 +324,13 @@ namespace Spring.Data.NHibernate.Support //reconnect existing one. if (conversation.DbProvider != null) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"DoOpenSession: Conversation has a DbProvider: Id='{conversation.Id}'"); } if (!conversation.RootSessionPerConversation.IsConnected) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"DoOpenSession: Conversation is not Connected: Id='{conversation.Id}'"); } @@ -340,7 +342,7 @@ namespace Spring.Data.NHibernate.Support } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"DoOpenSession: Conversation is already Connected: Id='{conversation.Id}'"); } @@ -348,7 +350,7 @@ namespace Spring.Data.NHibernate.Support } else { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"DoOpenSession: Conversation has NO DbProvider: Id='{conversation.Id}'"); } @@ -382,7 +384,7 @@ namespace Spring.Data.NHibernate.Support /// public LazySessionPerConversationHolder(SessionPerConversationScope owner, IConversationState activeConversation, ICollection allManagedConversation) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Created LazyReconnectableSessionHolder"); } @@ -402,7 +404,7 @@ namespace Spring.Data.NHibernate.Support if (activeConversation.RootSessionPerConversation == null || !activeConversation.RootSessionPerConversation.IsConnected) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("EnsureInitialized: 'session-per-conversation' instance requested - opening new session"); } @@ -422,7 +424,7 @@ namespace Spring.Data.NHibernate.Support activeConversation = null; allManagedConversation = null; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("CloseAll LazySessionPerConversationHolder"); } @@ -430,7 +432,7 @@ namespace Spring.Data.NHibernate.Support private void CloseConversation(IConversationState conversation) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug($"CloseConversation: Id='{conversation.Id}'"); } @@ -454,7 +456,7 @@ namespace Spring.Data.NHibernate.Support } RemoveSession(tmpSession); } - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("Closed LazySessionPerConversationHolder"); } diff --git a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/HttpModule/ConversationModule.cs b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/HttpModule/ConversationModule.cs index 6f668fe1..36253536 100644 --- a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/HttpModule/ConversationModule.cs +++ b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/HttpModule/ConversationModule.cs @@ -20,6 +20,7 @@ using System.Web; using System.Web.UI; +using Microsoft.Extensions.Logging; using Spring.Context; namespace Spring.Web.Conversation.HttpModule @@ -74,10 +75,10 @@ namespace Spring.Web.Conversation.HttpModule if (HttpContext.Current.Session != null) { - if (LOG.IsDebugEnabled) LOG.Debug("context_PreRequestHandlerExecute: Processing HttpContext.Current.Session"); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("context_PreRequestHandlerExecute: Processing HttpContext.Current.Session"); foreach (String convMngName in this.ConversationManagerNameList) { - if (LOG.IsDebugEnabled) LOG.Debug(string.Format("context_PreRequestHandlerExecute: Processing ConversationManager: {0}", convMngName)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(string.Format("context_PreRequestHandlerExecute: Processing ConversationManager: {0}", convMngName)); IConversationManager convMng = (IConversationManager)this.applicationContext.GetObject(convMngName); convMng.EndOnTimeOut(); convMng.FreeEnded(); @@ -85,7 +86,7 @@ namespace Spring.Web.Conversation.HttpModule } else { - if (LOG.IsDebugEnabled) LOG.Debug("context_PreRequestHandlerExecute: no HttpContext.Current.Session found."); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("context_PreRequestHandlerExecute: no HttpContext.Current.Session found."); } } } @@ -101,10 +102,10 @@ namespace Spring.Web.Conversation.HttpModule /// void page_Unload(object sender, EventArgs e) { - if (LOG.IsDebugEnabled) LOG.Debug("page_Unload HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("page_Unload HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); foreach (String convMngName in this.ConversationManagerNameList) { - if (LOG.IsDebugEnabled) LOG.Debug(string.Format("page_Unload: Processing ConversationManager: {0}", convMngName)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(string.Format("page_Unload: Processing ConversationManager: {0}", convMngName)); IConversationManager convMng = (IConversationManager)this.applicationContext.GetObject(convMngName); convMng.EndOnTimeOut(); convMng.FreeEnded(); @@ -114,12 +115,12 @@ namespace Spring.Web.Conversation.HttpModule void context_EndRequest(object sender, EventArgs e) { - if (LOG.IsDebugEnabled) LOG.Debug("context_EndRequest HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("context_EndRequest HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); } void context_PostRequestHandlerExecute(object sender, EventArgs e) { - if (LOG.IsDebugEnabled) LOG.Debug("context_PostRequestHandlerExecute HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("context_PostRequestHandlerExecute HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); if (HttpContext.Current.Session != null) { } diff --git a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/InnerConversationList.cs b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/InnerConversationList.cs index ec25535d..1f79fcfd 100644 --- a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/InnerConversationList.cs +++ b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/InnerConversationList.cs @@ -19,6 +19,7 @@ #endregion using System.Collections; +using Microsoft.Extensions.Logging; using Spring.Collections.Generic; namespace Spring.Web.Conversation @@ -49,7 +50,7 @@ namespace Spring.Web.Conversation LOG.Error(message); throw new InvalidOperationException(message); } - if (LOG.IsDebugEnabled) LOG.Error(String.Format("Creating InnerConversationList for '{0}'", conversationOwner.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Error(String.Format("Creating InnerConversationList for '{0}'", conversationOwner.Id)); this.conversationOwner = conversationOwner; } @@ -59,7 +60,7 @@ namespace Spring.Web.Conversation /// private void PreAddProcessor(IConversationState itemAdded) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("PreAddProcessor: added={0} into {1}", itemAdded, this.conversationOwner)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("PreAddProcessor: added={0} into {1}", itemAdded, this.conversationOwner)); this.ValidateCircularDependency(itemAdded); if (itemAdded.ParentConversation != null && itemAdded.ParentConversation != this.conversationOwner) { @@ -73,7 +74,7 @@ namespace Spring.Web.Conversation /// private void PostAddProcessor(IConversationState itemAdded) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("PostAddProcessor: added={0} into {1}", itemAdded, this.conversationOwner)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("PostAddProcessor: added={0} into {1}", itemAdded, this.conversationOwner)); if (itemAdded.ParentConversation == null) { itemAdded.ParentConversation = this.conversationOwner; @@ -82,7 +83,7 @@ namespace Spring.Web.Conversation private void ValidateCircularDependency(IConversationState itemAdded) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Validating Circular Dependency: added={0} into {1}", itemAdded, this.conversationOwner)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("Validating Circular Dependency: added={0} into {1}", itemAdded, this.conversationOwner)); ICollection visitedColl = new HashedSet(); visitedColl.Add(conversationOwner); diff --git a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationManager.cs b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationManager.cs index c6521e8a..93183c85 100644 --- a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationManager.cs +++ b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationManager.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using NHibernate; using Spring.Context; using Spring.Context.Support; @@ -79,7 +80,7 @@ namespace Spring.Web.Conversation { try { - if (LOG.IsDebugEnabled) LOG.Debug("EndOnTimeOut"); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("EndOnTimeOut"); this.MutexEditDic.WaitOne(5000); foreach (String keyItem in this.conversations.Keys) { @@ -88,7 +89,7 @@ namespace Spring.Web.Conversation { if (DateTime.Now.Subtract(conversationItem.LastAccess).TotalMilliseconds > conversationItem.TimeOut) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Timeout for conversation '{0}'", conversationItem.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("Timeout for conversation '{0}'", conversationItem.Id)); conversationItem.EndConversation(); } } @@ -119,7 +120,7 @@ namespace Spring.Web.Conversation { try { - if (LOG.IsDebugEnabled) LOG.Debug("EndOnTimeOut"); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("EndOnTimeOut"); this.MutexEditDic.WaitOne(5000); List removeList = new List(); foreach (String keyItem in this.conversations.Keys) @@ -127,7 +128,7 @@ namespace Spring.Web.Conversation IConversationState conversationItem = this.conversations[keyItem]; if (conversationItem.Ended) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("FreeEnded: Release conversation '{0}'", conversationItem.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("FreeEnded: Release conversation '{0}'", conversationItem.Id)); removeList.Add(conversationItem); } } @@ -139,7 +140,7 @@ namespace Spring.Web.Conversation foreach (IConversationState conversationItem in removeList) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("FreeEnded: Remove conversation '{0}'", conversationItem.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("FreeEnded: Remove conversation '{0}'", conversationItem.Id)); conversationItem.EndConversation(); this.RemoveConversation(conversationItem); } @@ -183,7 +184,7 @@ namespace Spring.Web.Conversation /// public void SetActiveConversation(IConversationState conversation) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("SetActiveConversation('{0}')", conversation.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("SetActiveConversation('{0}')", conversation.Id)); //Close connection for the last conversation, if it is open. if (this.activeConversation != null && this.activeConversation != conversation) @@ -264,10 +265,10 @@ namespace Spring.Web.Conversation /// public override void Dispose() { - if (LOG.IsDebugEnabled) LOG.Debug("Dispose. End all Conversations"); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug("Dispose. End all Conversations"); foreach (String conversationId in this.conversations.Keys) { - if (LOG.IsDebugEnabled) LOG.Debug(string.Format("Ending Conversation for Conversation Id: {0}", conversationId)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(string.Format("Ending Conversation for Conversation Id: {0}", conversationId)); this.conversations[conversationId].EndConversation(); } diff --git a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationSpringState.cs b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationSpringState.cs index 9f8222a6..374613a2 100644 --- a/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationSpringState.cs +++ b/src/Spring/Spring.Web.Conversation.NHibernate5/Web/Conversation/WebConversationSpringState.cs @@ -20,6 +20,7 @@ using System.Collections; using System.Web; +using Microsoft.Extensions.Logging; using NHibernate; using Spring.Context; using Spring.Context.Support; @@ -72,7 +73,7 @@ namespace Spring.Web.Conversation /// public void EndConversation() { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("End of Conversation '{0}'", this.id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("End of Conversation '{0}'", this.id)); IDictionary springSessionScope = (IDictionary)HttpContext.Current.Session[SPRING_SESSSION_SCOPE_KEY]; if (springSessionScope == null) @@ -82,12 +83,12 @@ namespace Spring.Web.Conversation if (springSessionScope.Contains(this.Id)) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("EndConversation: Id='{0}' Was Found on 'spring session scope'!", this.id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("EndConversation: Id='{0}' Was Found on 'spring session scope'!", this.id)); springSessionScope.Remove(this.id); } else { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("EndConversation: Id='{0}' Was NOT Found on 'spring session scope!", this.id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("EndConversation: Id='{0}' Was NOT Found on 'spring session scope!", this.id)); } List innerConversationsListTemp = new List(this.InnerConversations); @@ -226,11 +227,11 @@ namespace Spring.Web.Conversation } if (this.ConversationManager != null) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("StartResumeConversation('{0}'): ConversationManager is not null.", this.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("StartResumeConversation('{0}'): ConversationManager is not null.", this.Id)); //if this is the root conversation. if (this.ParentConversation == null) { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("SetActiveConversation('{0}'): ConversationManager is not null.", this.Id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("SetActiveConversation('{0}'): ConversationManager is not null.", this.Id)); //if this is the root conversation. this.ConversationManager.SetActiveConversation(this); @@ -387,7 +388,7 @@ namespace Spring.Web.Conversation { throw new InvalidOperationException(String.Format("Id is different from spring name for this instance.. Currents='{0}', springName='{1}'", this.id, value)); } - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Begin of Conversation '{0}'", this.id)); + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("Begin of Conversation '{0}'", this.id)); } } diff --git a/src/Spring/Spring.Web.Mvc5/Context/Support/MvcApplicationContext.cs b/src/Spring/Spring.Web.Mvc5/Context/Support/MvcApplicationContext.cs index 0fc14695..373f36d0 100644 --- a/src/Spring/Spring.Web.Mvc5/Context/Support/MvcApplicationContext.cs +++ b/src/Spring/Spring.Web.Mvc5/Context/Support/MvcApplicationContext.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Core.IO; namespace Spring.Context.Support @@ -68,7 +69,7 @@ namespace Spring.Context.Support Refresh(); - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("created instance " + this); } diff --git a/src/Spring/Spring.Web.Mvc5/SpringMvcDependencyResolver.cs b/src/Spring/Spring.Web.Mvc5/SpringMvcDependencyResolver.cs index 745c31ec..93f97e65 100644 --- a/src/Spring/Spring.Web.Mvc5/SpringMvcDependencyResolver.cs +++ b/src/Spring/Spring.Web.Mvc5/SpringMvcDependencyResolver.cs @@ -1,5 +1,6 @@ using System.Collections.Concurrent; using System.Web.Mvc; +using Microsoft.Extensions.Logging; using Spring.Context; using Spring.Context.Support; @@ -117,9 +118,9 @@ namespace Spring.Web.Mvc { _nonResolvableTypes.Add(serviceType); - if (logger.IsDebugEnabled) + if (logger.IsEnabled(LogLevel.Debug)) { - logger.DebugFormat("could not find service from Spring container with type: {0}", serviceType); + logger.LogDebug("Could not find service from Spring container with type: {ServiceType}", serviceType); } } } diff --git a/src/Spring/Spring.Web/Caching/AspNetCache.cs b/src/Spring/Spring.Web/Caching/AspNetCache.cs index ce62f346..dcefd694 100644 --- a/src/Spring/Spring.Web/Caching/AspNetCache.cs +++ b/src/Spring/Spring.Web/Caching/AspNetCache.cs @@ -21,6 +21,7 @@ using System.Collections; using System.Web; using System.Web.Caching; +using Microsoft.Extensions.Logging; using Spring.Util; namespace Spring.Caching @@ -203,7 +204,7 @@ namespace Spring.Caching { if (key != null) { - if (Log.IsDebugEnabled) Log.Debug(string.Format("removing item '{0}' from cache '{1}'", key, this._cacheName)); + if (Log.IsEnabled(LogLevel.Debug)) Log.Debug(string.Format("removing item '{0}' from cache '{1}'", key, this._cacheName)); _cache.Remove(GenerateKey(key)); } } @@ -273,7 +274,7 @@ namespace Spring.Caching AssertUtils.ArgumentNotNull(key, "key"); AssertUtils.State( TimeSpan.Zero <= timeToLive, "timeToLive" ); - if (Log.IsDebugEnabled) Log.Debug(string.Format("adding item '{0}' to cache '{1}'", key, this._cacheName)); + if (Log.IsEnabled(LogLevel.Debug)) Log.Debug(string.Format("adding item '{0}' to cache '{1}'", key, this._cacheName)); if (TimeSpan.Zero < timeToLive) { diff --git a/src/Spring/Spring.Web/Context/Support/HttpApplicationConfigurer.cs b/src/Spring/Spring.Web/Context/Support/HttpApplicationConfigurer.cs index db225de2..88ef22dd 100644 --- a/src/Spring/Spring.Web/Context/Support/HttpApplicationConfigurer.cs +++ b/src/Spring/Spring.Web/Context/Support/HttpApplicationConfigurer.cs @@ -146,4 +146,4 @@ namespace Spring.Context.Support } } } -} \ No newline at end of file +} diff --git a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs index 167627d9..27d3865b 100644 --- a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs +++ b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs @@ -24,6 +24,7 @@ using System.Reflection; using System.Web; using System.Web.Hosting; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Xml; @@ -120,7 +121,7 @@ namespace Spring.Context.Support // remember creation info for debug output this._constructionTimeStamp = DateTime.Now; this._constructionUrl = VirtualEnvironment.CurrentVirtualPathAndQuery; - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("created instance " + this.ToString()); } @@ -200,7 +201,7 @@ namespace Spring.Context.Support lock (s_webContextCache) { ILog s_weblog = LogManager.GetLogger(typeof(WebApplicationContext)); - if (s_weblog.IsDebugEnabled) + if (s_weblog.IsEnabled(LogLevel.Debug)) { s_weblog.Debug("received ContextRegistry.Cleared event - clearing webContextCache"); } @@ -246,7 +247,7 @@ namespace Spring.Context.Support } ILog s_weblog = LogManager.GetLogger(typeof(WebApplicationContext)); - bool isLogDebugEnabled = s_weblog.IsDebugEnabled; + bool isLogDebugEnabled = s_weblog.IsEnabled(LogLevel.Debug); lock (s_webContextCache) { @@ -312,7 +313,7 @@ namespace Spring.Context.Support } catch (Exception ex) { - if (s_weblog.IsErrorEnabled) + if (s_weblog.IsEnabled(LogLevel.Error)) { s_weblog.Error(string.Format("failed creating context '{0}', Stacktrace:\n{1}", contextName, new StackTrace()), ex); } diff --git a/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs b/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs index 996cbbe4..667aa705 100644 --- a/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs +++ b/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs @@ -22,6 +22,7 @@ using System.Web.Configuration; using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Util; #endregion @@ -101,7 +102,7 @@ namespace Spring.Context.Support if (ContextRegistry.IsContextRegistered(contextName)) { IApplicationContext ctx = ContextRegistry.GetContext(contextName); - if (Log.IsDebugEnabled) + if (Log.IsEnabled(LogLevel.Debug)) { Log.Debug( string.Format("web context '{0}' already registered - returning existing instance {1}", diff --git a/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs b/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs index bd92e109..34580fc2 100644 --- a/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs +++ b/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs @@ -26,6 +26,7 @@ using System.Web.Caching; using System.Web.Routing; using System.Web.SessionState; using System.Web.UI; +using Microsoft.Extensions.Logging; using Spring.Core.IO; using Spring.Core.TypeConversion; using Spring.Core.TypeResolution; @@ -313,7 +314,7 @@ namespace Spring.Context.Support else { // this is an async session timeout - log as fatal since this is the thread's exit point! - s_log.Fatal(msg, ex); + s_log.LogCritical(ex, msg); } } finally diff --git a/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs b/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs index 5d8103dc..5deaae66 100644 --- a/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs +++ b/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs @@ -24,6 +24,7 @@ using System.Collections; using System.Web; using System.Web.Caching; using System.Web.SessionState; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Context.Attributes; using Spring.Context.Support; @@ -81,7 +82,7 @@ namespace Spring.Objects.Factory.Support { if (s_eventHandlersRegistered) return; - if (log.IsDebugEnabled) log.Debug("hooking up event handlers"); + if (log.IsEnabled(LogLevel.Debug)) log.Debug("hooking up event handlers"); VirtualEnvironment.EndRequest += OnEndRequest; VirtualEnvironment.EndSession += OnEndSession; @@ -529,7 +530,8 @@ namespace Spring.Objects.Factory.Support } catch (Exception ex) { - log.Fatal(string.Format("error during disposing session item with key '{0}'", key), ex); + string message = string.Format("error during disposing session item with key '{0}'", key); + log.LogCritical(ex, message); } } } diff --git a/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectUtils.cs b/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectUtils.cs index bdbba9b2..27e5a216 100644 --- a/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectUtils.cs +++ b/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectUtils.cs @@ -18,6 +18,7 @@ #endregion +using Microsoft.Extensions.Logging; using Spring.Util; using IHttpHandler = System.Web.IHttpHandler; using HttpException = System.Web.HttpException; @@ -65,7 +66,7 @@ namespace Spring.Objects.Factory.Support /// public static IHttpHandler CreatePageInstance( string pageUrl ) { - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( "creating page instance '" + pageUrl + "'" ); } @@ -178,19 +179,19 @@ namespace Spring.Objects.Factory.Support /// public static Type GetCompiledPageType( string pageUrl ) { - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( "getting page type for " + pageUrl ); } string rootedVPath = WebUtils.CombineVirtualPaths( VirtualEnvironment.CurrentExecutionFilePath, pageUrl ); - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( "page vpath is " + rootedVPath ); } Type pageType = VirtualEnvironment.GetCompiledType(rootedVPath); - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( string.Format( "got page type '{0}' for vpath '{1}'", pageType.FullName, rootedVPath ) ); } @@ -204,7 +205,7 @@ namespace Spring.Objects.Factory.Support public static Type GetControlType( string controlName ) { AssertUtils.ArgumentHasText( controlName, "controlName" ); - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( "getting control type for " + controlName ); } @@ -217,7 +218,7 @@ namespace Spring.Objects.Factory.Support string rootedVPath = WebUtils.CombineVirtualPaths( VirtualEnvironment.CurrentExecutionFilePath, controlName ); - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( "control vpath is " + rootedVPath ); } @@ -237,7 +238,7 @@ namespace Spring.Objects.Factory.Support throw; } - if (s_log.IsDebugEnabled) + if (s_log.IsEnabled(LogLevel.Debug)) { s_log.Debug( string.Format( "got control type '{0}' for vpath '{1}'", controlType.FullName, rootedVPath ) ); } diff --git a/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs b/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs index dc557d5c..c09eed85 100644 --- a/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs +++ b/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs @@ -19,6 +19,7 @@ #endregion using System.Xml; +using Microsoft.Extensions.Logging; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; using Spring.Util; @@ -147,7 +148,7 @@ namespace Spring.Objects.Factory.Xml { #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug(string.Format("Error while parsing object scope : '{0}' is an invalid value.", value), ex); diff --git a/src/Spring/Spring.Web/Util/VirtualEnvironment.cs b/src/Spring/Spring.Web/Util/VirtualEnvironment.cs index bf28febf..c5a11bf6 100644 --- a/src/Spring/Spring.Web/Util/VirtualEnvironment.cs +++ b/src/Spring/Spring.Web/Util/VirtualEnvironment.cs @@ -26,6 +26,7 @@ using System.Web; using System.Web.Caching; using System.Web.Compilation; using System.Web.SessionState; +using Microsoft.Extensions.Logging; #endregion @@ -259,7 +260,7 @@ namespace Spring.Util #region Instrumentation - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("rewriting path from " + currentFileDirectory + " to " + newPath + " results in " + ctx.Request.FilePath); } @@ -272,7 +273,7 @@ namespace Spring.Util { if (originalPath != null) { - if (log.IsDebugEnabled) + if (log.IsEnabled(LogLevel.Debug)) { log.Debug("restoring path from " + ctx.Request.FilePath + " back to " + originalPath); } diff --git a/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs b/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs index 2a5c2a4e..3c52a2b8 100644 --- a/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs +++ b/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs @@ -25,6 +25,7 @@ using System.Security; using System.Security.Permissions; using System.Web; using System.Web.UI; +using Microsoft.Extensions.Logging; using Spring.Collections; using Spring.Context; using Spring.Context.Support; @@ -166,7 +167,7 @@ namespace Spring.Web.Support /// public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string url, string physicalPath) { - bool isDebug = Log.IsDebugEnabled; + bool isDebug = Log.IsEnabled(LogLevel.Debug); #region Instrumentation @@ -294,7 +295,7 @@ namespace Spring.Web.Support protected internal static NamedObjectDefinition FindWebObjectDefinition(string appRelativeVirtualPath, IConfigurableListableObjectFactory objectFactory) { ILog Log = LogManager.GetLogger(typeof(AbstractHandlerFactory)); - bool isDebug = Log.IsDebugEnabled; + bool isDebug = Log.IsEnabled(LogLevel.Debug); // lookup definition using app-relative url if (isDebug) diff --git a/src/Spring/Spring.Web/Web/Support/HandlerMap.cs b/src/Spring/Spring.Web/Web/Support/HandlerMap.cs index 63b9d72c..656c2712 100644 --- a/src/Spring/Spring.Web/Web/Support/HandlerMap.cs +++ b/src/Spring/Spring.Web/Web/Support/HandlerMap.cs @@ -23,6 +23,7 @@ using System.Collections; using System.Text.RegularExpressions; using System.Web; +using Microsoft.Extensions.Logging; #endregion @@ -66,18 +67,18 @@ namespace Spring.Web.Support /// the object name public HandlerMapEntry MapPath( string virtualPath ) { - if(Log.IsDebugEnabled) Log.Debug( string.Format( "looking up mapping for url '{0}'", virtualPath ) ); + if(Log.IsEnabled(LogLevel.Debug)) Log.Debug( string.Format( "looking up mapping for url '{0}'", virtualPath ) ); for(int i=0;i - - - + @@ -44,5 +42,9 @@ true TRACE;$(DefineConstants) + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs index b0f903b9..11cd4e42 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs @@ -20,7 +20,11 @@ #region Imports +using System; +using System.Collections.Generic; using System.Reflection; + + using NUnit.Framework; using Spring.Aop.Support; diff --git a/test/Spring/Spring.Aop.Tests/Aop/Support/SdkRegularExpressionMethodPointcutTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Support/SdkRegularExpressionMethodPointcutTests.cs index 79a5c032..00c37927 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Support/SdkRegularExpressionMethodPointcutTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Support/SdkRegularExpressionMethodPointcutTests.cs @@ -19,9 +19,9 @@ #endregion #region Imports - +using System; using System.Text.RegularExpressions; -using Common.Logging.Simple; +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using Spring.Util; @@ -44,7 +44,7 @@ namespace Spring.Aop.Support public void FixtureSetUp() { // enable (null appender) logging, to ensure that the logging code is exercised - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + LogManager.LoggerFactory = NullLoggerFactory.Instance; } /// diff --git a/test/Spring/Spring.Aop.Tests/Aop/Target/PrototypeTargetSourceTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Target/PrototypeTargetSourceTests.cs index c7fdee84..deca6121 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Target/PrototypeTargetSourceTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Target/PrototypeTargetSourceTests.cs @@ -18,10 +18,10 @@ #endregion -using Common.Logging.Simple; +using System; using FakeItEasy; - +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using Spring.Objects.Factory; @@ -44,7 +44,7 @@ namespace Spring.Aop.Target public void FixtureSetUp() { // enable (null appender) logging, just to ensure that the logging code is correct - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + LogManager.LoggerFactory = NullLoggerFactory.Instance; } /// diff --git a/test/Spring/Spring.Aop.Tests/Aspects/Exception/ExceptionHandlerAspectIntegrationTests.cs b/test/Spring/Spring.Aop.Tests/Aspects/Exception/ExceptionHandlerAspectIntegrationTests.cs index 9a9e71a5..e131798f 100644 --- a/test/Spring/Spring.Aop.Tests/Aspects/Exception/ExceptionHandlerAspectIntegrationTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aspects/Exception/ExceptionHandlerAspectIntegrationTests.cs @@ -20,9 +20,10 @@ #region Imports +using System; using System.Collections; -using Common.Logging.Simple; - +using System.Collections.Generic; +using Microsoft.Extensions.Logging; using NUnit.Framework; using Spring.Aop.Framework; using Spring.Objects; @@ -40,27 +41,65 @@ namespace Spring.Aspects.Exceptions public class ExceptionHandlerAspectIntegrationTests { private ExceptionHandlerAdvice exceptionHandlerAdvice; - private CapturingLoggerFactoryAdapter loggerFactoryAdapter; - private ILoggerFactoryAdapter originalAdapter; + private CapturingLoggerFactory loggerFactory; + private ILoggerFactory originalFactory; private static bool spelActionExecuted = false; [SetUp] public void Setup() { - originalAdapter = LogManager.Adapter; - loggerFactoryAdapter = new CapturingLoggerFactoryAdapter(); - LogManager.Adapter = loggerFactoryAdapter; + originalFactory = LogManager.LoggerFactory; + loggerFactory = new CapturingLoggerFactory(); + LogManager.LoggerFactory = loggerFactory; exceptionHandlerAdvice = new ExceptionHandlerAdvice(); } + public class CapturingLoggerFactory : ILoggerFactory + { + public List LoggerEvents { get; set; }= []; + + + public void Dispose() + { + } + + public ILogger CreateLogger(string categoryName) + { + return new CapturingLogger(LoggerEvents); + } + + public class CapturingLogger(List loggedEvents) : ILogger + { + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + var message = formatter(state, exception); + loggedEvents.Add(message); + } + + public bool IsEnabled(LogLevel logLevel) + { + return true; + } + + public IDisposable BeginScope(TState state) + { + return null; + } + } + + public void AddProvider(ILoggerProvider provider) + { + } + } + [TearDown] public void TearDown() { // loggerFactoryAdapter.LogMessages.Clear(); //reset so other tests can produce some output if needed. - loggerFactoryAdapter.Clear(); - LogManager.Adapter = originalAdapter; + loggerFactory.LoggerEvents.Clear(); + LogManager.LoggerFactory = originalFactory; } [Test] @@ -111,9 +150,9 @@ namespace Spring.Aspects.Exceptions catch (ArithmeticException) { bool found = false; - foreach (CapturingLoggerEvent loggerEvent in loggerFactoryAdapter.LoggerEvents) + foreach (var loggerEvent in loggerFactory.LoggerEvents) { - if (loggerEvent.RenderedMessage.IndexOf("Hello World") >= 0) + if (loggerEvent.IndexOf("Hello World") >= 0) { found = true; } @@ -481,15 +520,15 @@ namespace Spring.Aspects.Exceptions private void AssertSearchString(string searchString) { bool found = false; - foreach (CapturingLoggerEvent loggerEvent in loggerFactoryAdapter.LoggerEvents) + foreach (var loggerEvent in loggerFactory.LoggerEvents) { - if (loggerEvent.RenderedMessage.IndexOf(searchString) >= 0) + if (loggerEvent.IndexOf(searchString) >= 0) { found = true; } } Assert.IsTrue(found, "did not find logging output [" + searchString + "] Logging values = " - + StringUtils.CollectionToCommaDelimitedString(loggerFactoryAdapter.LoggerEvents)); + + StringUtils.CollectionToCommaDelimitedString(loggerFactory.LoggerEvents)); } } } diff --git a/test/Spring/Spring.Aop.Tests/Aspects/Logging/SimpleLoggingAdviceTests.cs b/test/Spring/Spring.Aop.Tests/Aspects/Logging/SimpleLoggingAdviceTests.cs index 3eca0ad5..f01d7d1b 100644 --- a/test/Spring/Spring.Aop.Tests/Aspects/Logging/SimpleLoggingAdviceTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aspects/Logging/SimpleLoggingAdviceTests.cs @@ -18,11 +18,14 @@ #endregion +using System; using System.Reflection; using AopAlliance.Intercept; -using FakeItEasy; +using FakeItEasy; +using FakeItEasy.Configuration; +using Microsoft.Extensions.Logging; using NUnit.Framework; using Spring.Aop.Framework; @@ -60,14 +63,14 @@ namespace Spring.Aspects.Logging SimpleLoggingAdvice loggingAdvice = new SimpleLoggingAdvice(log); pf.AddAdvice(loggingAdvice); - A.CallTo(() => log.IsTraceEnabled).Returns(true); + A.CallTo(() => log.IsEnabled(LogLevel.Trace)).Returns(true); object proxy = pf.GetProxy(); ITestTarget ptt = (ITestTarget)proxy; ptt.DoSomething(); - A.CallTo(() => log.Trace("Entering DoSomething")).MustHaveHappened(); - A.CallTo(() => log.Trace("Exiting DoSomething")).MustHaveHappened(); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Entering DoSomething"); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Exiting DoSomething"); } [Test] @@ -79,14 +82,14 @@ namespace Spring.Aspects.Logging MethodInfo mi = typeof(string).GetMethod("ToString", Type.EmptyTypes); //two additional calls the method are to retrieve the method name on entry/exit... A.CallTo(() => methodInvocation.Method).Returns(mi); - A.CallTo(() => log.IsTraceEnabled).Returns(true); + A.CallTo(() => log.IsEnabled(LogLevel.Trace)).Returns(true); A.CallTo(() => methodInvocation.Proceed()).Returns(null); TestableSimpleLoggingAdvice loggingAdvice = new TestableSimpleLoggingAdvice(true); loggingAdvice.CallInvokeUnderLog(methodInvocation, log); - A.CallTo(() => log.Trace("Entering ToString")).MustHaveHappened(); - A.CallTo(() => log.Trace("Exiting ToString")).MustHaveHappened(); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Entering ToString"); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Exiting ToString"); } [Test] @@ -99,8 +102,8 @@ namespace Spring.Aspects.Logging //two additional calls the method are to retrieve the method name on entry/exit... A.CallTo(() => methodInvocation.Method).Returns(mi); - A.CallTo(() => log.IsTraceEnabled).Returns(false); - A.CallTo(() => log.IsDebugEnabled).Returns(true); + A.CallTo(() => log.IsEnabled(LogLevel.Trace)).Returns(false); + A.CallTo(() => log.IsEnabled(LogLevel.Debug)).Returns(true); A.CallTo(() => methodInvocation.Proceed()).Returns(null); @@ -109,8 +112,8 @@ namespace Spring.Aspects.Logging Assert.IsTrue(loggingAdvice.CallIsInterceptorEnabled(methodInvocation, log)); loggingAdvice.CallInvokeUnderLog(methodInvocation, log); - A.CallTo(() => log.Debug("Entering ToString")).MustHaveHappened(); - A.CallTo(() => log.Debug("Exiting ToString")).MustHaveHappened(); + log.VerifyLogMustHaveHappened(LogLevel.Debug, "Entering ToString"); + log.VerifyLogMustHaveHappened(LogLevel.Debug, "Exiting ToString"); } [Test] @@ -122,7 +125,7 @@ namespace Spring.Aspects.Logging MethodInfo mi = typeof(string).GetMethod("ToString", Type.EmptyTypes); //two additional calls the method are to retrieve the method name on entry/exit... A.CallTo(() => methodInvocation.Method).Returns(mi); - A.CallTo(() => log.IsTraceEnabled).Returns(true); + A.CallTo(() => log.IsEnabled(LogLevel.Trace)).Returns(true); Exception e = new ArgumentException("bad value"); A.CallTo(() => methodInvocation.Proceed()).Throws(e); @@ -137,8 +140,8 @@ namespace Spring.Aspects.Logging { } - A.CallTo(() => log.Trace("Entering ToString")).MustHaveHappened(); - A.CallTo(() => log.Trace("Exception thrown in ToString, ToString", e)).MustHaveHappened(); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Entering ToString"); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Exception thrown in ToString, ToString"); } [Test] @@ -154,7 +157,7 @@ namespace Spring.Aspects.Logging object[] args = new object[] { "hello", luckyNumbers }; A.CallTo(() => methodInvocation.Arguments).Returns(args); - A.CallTo(() => log.IsTraceEnabled).Returns(true); + A.CallTo(() => log.IsEnabled(LogLevel.Trace)).Returns(true); A.CallTo(() => methodInvocation.Proceed()).Returns(4); TestableSimpleLoggingAdvice loggingAdvice = new TestableSimpleLoggingAdvice(true); @@ -164,8 +167,8 @@ namespace Spring.Aspects.Logging loggingAdvice.CallInvokeUnderLog(methodInvocation, log); - A.CallTo(() => log.Trace(A.That.StartsWith("Entering Bark"))).MustHaveHappened(); - A.CallTo(() => log.Trace(A.That.StartsWith("Exiting Bark"))).MustHaveHappened(); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Entering Bark"); + log.VerifyLogMustHaveHappened(LogLevel.Trace, "Exiting Bark"); } } @@ -176,4 +179,45 @@ namespace Spring.Aspects.Logging return 4; } } + + public static class LoggerExtensions + { + public static void VerifyLogMustHaveHappened(this ILogger logger, LogLevel level, string message) + { + try + { + logger.VerifyLog(level, message) + .MustHaveHappened(); + } + catch (Exception e) + { + throw new ExpectationException($"while verifying a call to log with message: \"{message}\"", e); + } + } + + public static void VerifyLogMustNotHaveHappened(this ILogger logger, LogLevel level, string message) + { + try + { + logger.VerifyLog(level, message) + .MustNotHaveHappened(); + } + catch (Exception e) + { + throw new ExpectationException($"while verifying a call to log with message: \"{message}\"", e); + } + } + + public static IVoidArgumentValidationConfiguration VerifyLog(this ILogger logger, LogLevel level, + string message) + { + return A.CallTo(() => logger.Log( + level, + A._, + A.That.Matches(e => e.ToString().Contains(message)), + A._, + A>._) + ); + } + } } diff --git a/test/Spring/Spring.Core.Tests/Core/IO/ResourceConverterTests.cs b/test/Spring/Spring.Core.Tests/Core/IO/ResourceConverterTests.cs index 42728f1f..1e1b6c8e 100644 --- a/test/Spring/Spring.Core.Tests/Core/IO/ResourceConverterTests.cs +++ b/test/Spring/Spring.Core.Tests/Core/IO/ResourceConverterTests.cs @@ -20,7 +20,8 @@ #region Imports -using Common.Logging.Simple; +using System; +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; #endregion @@ -41,7 +42,7 @@ namespace Spring.Core.IO public void FixtureSetUp() { // enable (null appender) logging, just to ensure that the logging code is correct - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + LogManager.LoggerFactory = NullLoggerFactory.Instance; } [Test] @@ -116,4 +117,4 @@ namespace Spring.Core.IO } } -} \ No newline at end of file +} diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/LogFactoryObjectTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/LogFactoryObjectTests.cs index c32e658c..f8f3a160 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/LogFactoryObjectTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/LogFactoryObjectTests.cs @@ -20,6 +20,7 @@ #region Imports +using System; using NUnit.Framework; #endregion @@ -124,4 +125,4 @@ namespace Spring.Objects.Factory.Config "Mmm... the LogFactoryObject class ain't giving back ILog types (it must)."); } } -} \ No newline at end of file +} diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/PropertyOverrideConfigurerTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/PropertyOverrideConfigurerTests.cs index 492a0f4e..97a123b9 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/PropertyOverrideConfigurerTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/PropertyOverrideConfigurerTests.cs @@ -19,10 +19,9 @@ #endregion using System.Collections.Specialized; -using Common.Logging.Simple; using FakeItEasy; - +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using Spring.Context.Support; using Spring.Core.IO; @@ -49,7 +48,7 @@ namespace Spring.Objects.Factory.Config public void FixtureSetUp() { // enable (null appender) logging, just to ensure that the logging code is correct - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + LogManager.LoggerFactory = NullLoggerFactory.Instance; } [Test] @@ -178,4 +177,4 @@ namespace Spring.Objects.Factory.Config Assert.AreEqual("Overriden Name", to.Name); } } -} \ No newline at end of file +} diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs index 541369a6..6254908b 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs @@ -18,9 +18,12 @@ #endregion +using System; using System.Collections; +using System.IO; +using System.Linq; using System.Text; -using Common.Logging.Simple; +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using Spring.Collections; using Spring.Core.IO; @@ -45,7 +48,7 @@ namespace Spring.Objects.Factory.Xml public void FixtureSetUp() { // enable (null appender) logging, to ensure that the logging code is exercised... - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + LogManager.LoggerFactory = NullLoggerFactory.Instance; //XmlConfigurator.Configure(); } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs index 47c21e77..010d4cd2 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs @@ -14,18 +14,19 @@ * limitations under the License. */ +using System; using System.Collections; using System.Data; using System.Globalization; +using System.IO; using System.Text; +using System.Threading; #if !NETCOREAPP using System.Web.Services; #endif -using Common.Logging.Simple; - using FakeItEasy; - +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using Spring.Core.IO; @@ -56,7 +57,7 @@ namespace Spring.Objects.Factory.Xml { // enable (null appender) logging, to ensure that the logging code is exercised... //XmlConfigurator.Configure(); - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + LogManager.LoggerFactory = NullLoggerFactory.Instance; } [SetUp] diff --git a/test/Spring/Spring.Core.Tests/Objects/ObjectWrapperTests.cs b/test/Spring/Spring.Core.Tests/Objects/ObjectWrapperTests.cs index 67207587..0f97abc7 100644 --- a/test/Spring/Spring.Core.Tests/Objects/ObjectWrapperTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/ObjectWrapperTests.cs @@ -20,13 +20,17 @@ #region Imports +using System; using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Globalization; +using System.IO; using System.Reflection; using System.Runtime.CompilerServices; -using Common.Logging.Simple; + +using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; using Spring.Collections; using Spring.Core; @@ -53,8 +57,8 @@ namespace Spring.Objects [OneTimeSetUp] public void FixtureSetUp() { - // enable logging (to nowhere), just to exercisee the logging code... - LogManager.Adapter = new NoOpLoggerFactoryAdapter(); + // enable logging (to nowhere), just to exercise the logging code... + LogManager.LoggerFactory = NullLoggerFactory.Instance; } #region Classes Used During Tests @@ -1599,4 +1603,4 @@ namespace Spring.Objects wrapper.GetPropertyInfo("Bar"); } } -} \ No newline at end of file +} diff --git a/test/Spring/Spring.Messaging.Ems.Integration.Tests/Messaging/Ems/Core/SimpleMessageListener.cs b/test/Spring/Spring.Messaging.Ems.Integration.Tests/Messaging/Ems/Core/SimpleMessageListener.cs index 47bc6ba8..e14b63bc 100644 --- a/test/Spring/Spring.Messaging.Ems.Integration.Tests/Messaging/Ems/Core/SimpleMessageListener.cs +++ b/test/Spring/Spring.Messaging.Ems.Integration.Tests/Messaging/Ems/Core/SimpleMessageListener.cs @@ -1,3 +1,4 @@ + namespace Spring.Messaging.Ems.Core { public class SimpleMessageListener : IMessageListener diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/LoggingExceptionHandler.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/LoggingExceptionHandler.cs index 920e9324..16a45329 100644 --- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/LoggingExceptionHandler.cs +++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/LoggingExceptionHandler.cs @@ -1,4 +1,6 @@ +using System; using System.Messaging; +using System.Threading; namespace Spring.Messaging.Listener { diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/SimpleHandler.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/SimpleHandler.cs index 35d4872d..1322c20a 100644 --- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/SimpleHandler.cs +++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/SimpleHandler.cs @@ -1,3 +1,7 @@ + + +using System; + namespace Spring.Messaging.Listener { public class SimpleHandler diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/WaitingHandler.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/WaitingHandler.cs index 5e2b0053..409f297e 100644 --- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/WaitingHandler.cs +++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/WaitingHandler.cs @@ -1,3 +1,8 @@ + + +using System; +using System.Threading; + namespace Spring.Messaging.Listener { public class WaitingHandler diff --git a/test/Spring/Spring.Services.Tests/EnterpriseServices/ExeConfigurationSystemTests.cs b/test/Spring/Spring.Services.Tests/EnterpriseServices/ExeConfigurationSystemTests.cs index fd4b3bec..c712e199 100644 --- a/test/Spring/Spring.Services.Tests/EnterpriseServices/ExeConfigurationSystemTests.cs +++ b/test/Spring/Spring.Services.Tests/EnterpriseServices/ExeConfigurationSystemTests.cs @@ -20,15 +20,12 @@ using System.Configuration; using System.Configuration.Internal; -using Common.Logging.Configuration; -using Common.Logging.Simple; +using System.IO; using NUnit.Framework; using Spring.Util; namespace Spring.EnterpriseServices { - - [TestFixture] public class ExeConfigurationSystemTests { @@ -43,9 +40,6 @@ namespace Spring.EnterpriseServices { ExeConfigurationSystem ccs = new ExeConfigurationSystem(exePath); prevConfig = ConfigurationUtils.SetConfigurationSystem(ccs, true); - LogSetting settings = (LogSetting) ConfigurationManager.GetSection("logging"); - Assert.AreEqual(typeof (TraceLoggerFactoryAdapter), settings.FactoryAdapterType); - Assert.AreEqual("from custom config!", ConfigurationManager.AppSettings["key"]); Assert.IsNull(ConfigurationManager.GetSection("spring/context")); diff --git a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/SerializeConversationTestModule.cs b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/SerializeConversationTestModule.cs index 40e42476..ed5fe2d7 100644 --- a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/SerializeConversationTestModule.cs +++ b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/SerializeConversationTestModule.cs @@ -22,6 +22,7 @@ using System.Web; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; using System.Reflection; +using Microsoft.Extensions.Logging; namespace Spring.Web.Conversation { @@ -33,7 +34,7 @@ namespace Spring.Web.Conversation { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(SerializeConversationTestModule)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(SerializeConversationTestModule)); #endregion @@ -139,11 +140,11 @@ namespace Spring.Web.Conversation { #region Logging - private Common.Logging.ILog LOG + private ILog LOG { get { - return Common.Logging.LogManager.GetLogger(typeof(SerializeConversationTestModule)); + return LogManager.GetLogger(typeof(SerializeConversationTestModule)); } } @@ -151,7 +152,7 @@ namespace Spring.Web.Conversation public override Type BindToType(string assemblyName, string typeName) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("MyBinder.BindToType: {0}, {1}", typeName, assemblyName)); return Type.GetType(typeName + ", " + assemblyName); } @@ -201,7 +202,7 @@ namespace Spring.Web.Conversation { #region Logging - private static readonly Common.Logging.ILog LOG = Common.Logging.LogManager.GetLogger(typeof(SerializeConversationTestModule)); + private static readonly ILog LOG = LogManager.GetLogger(typeof(SerializeConversationTestModule)); #endregion @@ -209,7 +210,7 @@ namespace Spring.Web.Conversation public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("MySerializationSurrogateWrapper.GetObjectData({0},...", obj.GetType())); FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy); @@ -231,7 +232,7 @@ namespace Spring.Web.Conversation public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { - if (LOG.IsDebugEnabled) + if (LOG.IsEnabled(LogLevel.Debug)) LOG.Debug(String.Format("MySerializationSurrogateWrapper.SetObjectData({0},...", obj.GetType())); FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); diff --git a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/WebConversationStateTest.cs b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/WebConversationStateTest.cs index ba49fb76..6b0c2b5d 100644 Binary files a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/WebConversationStateTest.cs and b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Conversation/WebConversationStateTest.cs differ diff --git a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/CircularDependenceTest.aspx.cs b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/CircularDependenceTest.aspx.cs index 849216c6..45fd3b6a 100644 --- a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/CircularDependenceTest.aspx.cs +++ b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/CircularDependenceTest.aspx.cs @@ -1,8 +1,10 @@ +using System; using System.Text; - +using Spring; using Spring.Context; using Spring.Web.Conversation; + public partial class CircularDependenceTest : System.Web.UI.Page, IApplicationContextAware { private static readonly ILog LOG = LogManager.GetLogger(typeof(CircularDependenceTest)); diff --git a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/IoeTests.aspx.cs b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/IoeTests.aspx.cs index 329d542f..29139815 100644 --- a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/IoeTests.aspx.cs +++ b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/IoeTests.aspx.cs @@ -1,6 +1,7 @@ using Spring.Web.Conversation; using System.Text.RegularExpressions; using NHibernate; +using Spring; using Spring.Data.NHibernate.Support; using Spring.Objects.Factory; diff --git a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCLazyLoadTest_A_Status.aspx.cs b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCLazyLoadTest_A_Status.aspx.cs index 35a8eb23..bd25f7af 100644 --- a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCLazyLoadTest_A_Status.aspx.cs +++ b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCLazyLoadTest_A_Status.aspx.cs @@ -1,6 +1,7 @@ using Spring.Web.Conversation; using Spring.Entities; using NHibernate; +using Spring; public partial class SPCLazyLoadTest_A_Status : System.Web.UI.Page { diff --git a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCSwitchConversationSameRequest.aspx.cs b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCSwitchConversationSameRequest.aspx.cs index 706546fe..2975373e 100644 --- a/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCSwitchConversationSameRequest.aspx.cs +++ b/test/Spring/Spring.Web.Conversation.NHibernate5.Tests/Data/Spring/Conversation/WebConversationStateTest/SPCSwitchConversationSameRequest.aspx.cs @@ -1,6 +1,9 @@ +using System; + using Spring.Web.Conversation; using Spring.Entities; using NHibernate; +using Spring; public partial class SPCSwitchConversationSameRequest : System.Web.UI.Page { diff --git a/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs b/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs index 1859878f..e9eed3c0 100644 --- a/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs +++ b/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs @@ -39,12 +39,6 @@ namespace Spring.Context.Support [TestFixture] public class HttpApplicationConfigurerTests { - [OneTimeSetUp] - public void SetUpFixture() - { - LogManager.Adapter = new Common.Logging.Simple.TraceLoggerFactoryAdapter(); - } - [SetUp] public void SetUp() { diff --git a/test/Spring/Spring.Web.Tests/Data/Spring/Objects/Factory/Support/TestForm.aspx.cs b/test/Spring/Spring.Web.Tests/Data/Spring/Objects/Factory/Support/TestForm.aspx.cs index ceba416e..25972039 100644 --- a/test/Spring/Spring.Web.Tests/Data/Spring/Objects/Factory/Support/TestForm.aspx.cs +++ b/test/Spring/Spring.Web.Tests/Data/Spring/Objects/Factory/Support/TestForm.aspx.cs @@ -1,3 +1,5 @@ +using System; + namespace Spring.Data.Objects.Factory.Support { public class TestForm : Spring.Web.UI.Page diff --git a/test/Spring/Spring.Web.Tests/Web/Support/ControlInterceptionTests.cs b/test/Spring/Spring.Web.Tests/Web/Support/ControlInterceptionTests.cs index 1f65f807..e3678a28 100644 --- a/test/Spring/Spring.Web.Tests/Web/Support/ControlInterceptionTests.cs +++ b/test/Spring/Spring.Web.Tests/Web/Support/ControlInterceptionTests.cs @@ -40,11 +40,6 @@ namespace Spring.Web.Support private const string RES_OBJECTS = "assembly://Spring.Web.Tests/Spring.Web.Support/ControlInterceptionTests.objects.xml"; - static ControlInterceptionTests() - { - Common.Logging.LogManager.Adapter = new Common.Logging.Simple.TraceLoggerFactoryAdapter(); - } - [SetUp] public void SetUp() {