Switch to using MS logging abstractions (#267)

This commit is contained in:
Marko Lahma
2025-03-28 19:33:38 +02:00
committed by GitHub
parent 2e6687a60d
commit fda46d95b1
229 changed files with 1084 additions and 898 deletions

View File

@@ -5,9 +5,9 @@
<ItemGroup>
<PackageVersion Include="Apache.NMS" Version="2.0.0" />
<PackageVersion Include="Apache.NMS.ActiveMQ" Version="1.7.2" />
<PackageVersion Include="Common.Logging" Version="3.4.1" />
<PackageVersion Include="Common.Logging.Log4Net1213" Version="3.4.1" />
<PackageVersion Include="Common.Logging.Log4Net1215" Version="3.4.1" />
<PackageVersion Include="log4net" Version="3.0.4" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />

View File

@@ -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}"

View File

@@ -1,14 +1,14 @@
#region License
/*
* Copyright © 2002-2011 the original author or authors.
*
* Copyright <EFBFBD> 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
}
}
}

View File

@@ -11,6 +11,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
</Project>

View File

@@ -45,15 +45,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging">
<HintPath>..\..\..\..\..\lib\Net\2.0\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Common.Logging.Log4Net1211">
<HintPath>..\..\..\..\..\lib\Net\2.0\Common.Logging.Log4Net1211.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\..\..\..\lib\Net\4.0\log4net.dll</HintPath>
</Reference>
<Reference Include="Spring.Aop">
<HintPath>..\..\..\..\..\bin\net\4.0\debug\Spring.Aop.dll</HintPath>
</Reference>

View File

@@ -7,7 +7,7 @@
<ProjectReference Include="..\Primes\Primes.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>

View File

@@ -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);
}
}
}
}

View File

@@ -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;

View File

@@ -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<br />");
foreach (LoggingEvent loggingEvent in events)
{
layout.Format(stringWriter, loggingEvent);
}
results.Text = stringWriter.ToString();
}
}
protected void customerOrders_Click(object sender, EventArgs e)
{
SetResult("Back");

View File

@@ -42,7 +42,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Common.Logging.Log4Net1213" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />

View File

@@ -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<br />");
foreach (LoggingEvent loggingEvent in events)
{
layout.Format(stringWriter, loggingEvent);
}
results.Text = stringWriter.ToString();
}
}
protected void customerOrders_Click(object sender, EventArgs e)
{
SetResult("Back");

View File

@@ -42,7 +42,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Common.Logging.Log4Net1213" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />

View File

@@ -4,7 +4,7 @@
<RootNamespace>Spring</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<Reference Include="Spring.Core">

View File

@@ -2,9 +2,6 @@
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
@@ -12,17 +9,6 @@
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1215">
<!-- choices are INLINE, FILE, FILE-WATCH, EXTERNAL-->
<!-- otherwise BasicConfigurer.Configure is used -->
<!-- log4net configuration file is specified with key configFile-->
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<spring>
<context>

View File

@@ -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
}
}
}

View File

@@ -13,8 +13,8 @@
<EmbeddedResource Include="MovieFinder\*.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Common.Logging.Log4Net1215" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" />
</ItemGroup>
<ItemGroup>
<None Update="movies.txt">

View File

@@ -7,10 +7,6 @@
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<spring>

View File

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

View File

@@ -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));
/// <summary>
/// The main entry point for the application.
@@ -44,4 +44,4 @@ namespace Spring.MsmqQuickStart.Client
Application.Exit();
}
}
}
}

View File

@@ -41,6 +41,6 @@
<Content Include="Config\*.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
</Project>

View File

@@ -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
}
}
}

View File

@@ -7,10 +7,6 @@
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<spring>

View File

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

View File

@@ -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;
}
}
}
}

View File

@@ -20,6 +20,6 @@
<Content Include="Config\*.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
</Project>

View File

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

View File

@@ -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));
/// <summary>
/// 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();
}
}
}
}

View File

@@ -7,7 +7,7 @@
<ProjectReference Include="..\Spring.NmsQuickStart.Common\Spring.NmsQuickStart.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<Reference Include="Spring.Core">

View File

@@ -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
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -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
/// <param name="exception">The exception.</param>
public void OnException(Exception exception)
{
logger.Info("********* Caught exception *************", exception);
logger.LogInformation(exception, "********* Caught exception *************");
}
}
}
}

View File

@@ -8,7 +8,7 @@
<ProjectReference Include="..\Spring.NmsQuickStart.Common\Spring.NmsQuickStart.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>
<ItemGroup>
<Reference Include="Spring.Core">

View File

@@ -6,9 +6,6 @@
<ItemGroup>
<Content Include="spring-objects.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Spring\Spring.Scheduling.Quartz3\Spring.Scheduling.Quartz3.csproj" />
</ItemGroup>

View File

@@ -22,7 +22,6 @@
<EmbeddedResource Include="TxQuickStart\*.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging.Log4Net1215" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />

View File

@@ -48,9 +48,7 @@
</PropertyGroup>
<ItemGroup>
<Using Include="Common.Logging" />
<Using Include="Common.Logging.ILog" Alias="ILog" />
<Using Include="Common.Logging.LogManager" Alias="LogManager" />
<Using Include="Microsoft.Extensions.Logging.ILogger" Alias="ILog" />
</ItemGroup>
<ItemGroup>

View File

@@ -13,6 +13,7 @@
<PackageVersion Include="Microsoft.AspNet.WebApi.WebHost" Version="5.2.7" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageVersion Include="MSTest.TestFramework" Version="2.1.2" />
<PackageVersion Include="NHibernate" Version="5.5.2" />

View File

@@ -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 + "].");
}

View File

@@ -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}]");
}

View File

@@ -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));
}

View File

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

View File

@@ -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,

View File

@@ -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
{
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class.
/// The shared <see cref="ILog"/> instance for this class.
/// </summary>
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

View File

@@ -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
{
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// The <see cref="ILog"/> instance for this class.
/// </summary>
private static readonly ILog logger = LogManager.GetLogger<ProxyFactoryObject>();
@@ -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
/// </summary>
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));
}

View File

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

View File

@@ -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
}
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
protected readonly ILog logger = LogManager.GetLogger(typeof (AbstractPrototypeTargetSource));

View File

@@ -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...");
}

View File

@@ -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}' " +

View File

@@ -21,6 +21,8 @@
#region Imports
using System.Reflection;
using Spring.Caching;
using Spring.Context;
using Spring.Expressions;

View File

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

View File

@@ -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)
{

View File

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

View File

@@ -22,6 +22,8 @@ using System.Collections;
using System.Reflection;
using AopAlliance.Intercept;
using Spring.Util;
namespace Spring.Aspects.Exceptions

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
using Spring.Expressions;
namespace Spring.Aspects.Exceptions

View File

@@ -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
/// </returns>
protected virtual bool IsLogEnabled(ILog log)
{
return log.IsTraceEnabled;
return log.IsEnabled(LogLevel.Trace);
}
/// <summary>

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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<string> GetAllAssembliesInPath(string folderPath)
{
var assemblies = new List<string>();
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
/// <returns></returns>
protected virtual IEnumerable<Assembly> ApplyAssemblyFiltersTo(IEnumerable<Assembly> 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<string> assemblies = new List<string>();
IEnumerable<string> files = Directory.GetFiles(folderPath, extension, SearchOption.AllDirectories);
string[] files = Directory.GetFiles(folderPath, extension, SearchOption.AllDirectories);
foreach (string file in files)
{

View File

@@ -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");
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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
/// </summary>
public class ScannedGenericObjectDefinition : GenericObjectDefinition
{
private static readonly ILog Log = LogManager.GetCurrentClassLogger();
private static readonly ILog Log = LogManager.GetLogger<ScannedGenericObjectDefinition>();
/// <summary>
/// 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()

View File

@@ -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);
}
}

View File

@@ -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";
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// The <see cref="ILog"/> instance for this class.
/// </summary>
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
/// <seealso cref="Spring.Context.IApplicationEventPublisher.PublishEvent"/>
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 " +

View File

@@ -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(

View File

@@ -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<XmlNode> 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)
{

View File

@@ -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
{
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
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)
{

View File

@@ -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,

View File

@@ -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
{
/// <summary>
/// Gets or sets the current log provider based on logger factory.
/// </summary>
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<T> GetLogger<T>() => LoggerFactory?.CreateLogger<T>() ?? NullLogger<T>.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);
}

View File

@@ -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;

View File

@@ -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[] {});
}
}

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -24,11 +24,11 @@ namespace Spring.Objects.Factory.Config
{
/// <summary>
/// <see cref="Spring.Objects.Factory.IFactoryObject"/> implementation that
/// creates instances of the <see cref="Common.Logging.ILog"/> class.
/// creates instances of the <see cref="ILog"/> class.
/// </summary>
/// <remarks>
/// <p>
/// Typically used for retrieving shared <see cref="Common.Logging.ILog"/>
/// Typically used for retrieving shared <see cref="ILog"/>
/// instances for common topics (such as the 'DAL', 'BLL', etc). The
/// <see cref="LogFactoryObject.LogName"/>
/// property determines the name of the
@@ -36,7 +36,7 @@ namespace Spring.Objects.Factory.Config
/// </p>
/// </remarks>
/// <author>Rick Evans</author>
/// <seealso cref="Common.Logging.LogManager.GetLogger(string)"/>
/// <seealso cref="LogManager.GetLogger(string)"/>
[Serializable]
public class LogFactoryObject : IFactoryObject, IInitializingObject
{
@@ -57,7 +57,7 @@ namespace Spring.Objects.Factory.Config
/// class.
/// </summary>
/// <param name="logName">
/// The name of the <see cref="Common.Logging.ILog"/> instance served up by
/// The name of the <see cref="ILog"/> instance served up by
/// this factory.
/// </param>
/// <exception cref="System.ArgumentNullException">
@@ -72,11 +72,11 @@ namespace Spring.Objects.Factory.Config
#endregion
/// <summary>
/// The name of the <see cref="Common.Logging.ILog"/> instance served up by
/// The name of the <see cref="ILog"/> instance served up by
/// this factory.
/// </summary>
/// <value>
/// The name of the <see cref="Common.Logging.ILog"/> instance served up by
/// The name of the <see cref="ILog"/> instance served up by
/// this factory.
/// </value>
/// <exception cref="System.ArgumentNullException">

View File

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

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -19,6 +19,7 @@
#endregion
using System.Collections;
using Spring.Core;
using Spring.Util;

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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
/// </exception>
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
/// <seealso cref="Spring.Objects.Factory.Config.IDestructionAwareObjectPostProcessor.PostProcessBeforeDestruction"/>
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
/// <returns>A reference to another object in the factory.</returns>
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
/// <seealso cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessBeforeInitialization"/>
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
/// <seealso cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessAfterInitialization"/>
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}'");
}

View File

@@ -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
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
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 + "]");
}

View File

@@ -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();
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// The <see cref="ILog"/> instance for this class.
/// </summary>
[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
/// </summary>
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}'.");
}

View File

@@ -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++)
{

View File

@@ -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
/// <seealso cref="Spring.Objects.Factory.Config.IConfigurableListableObjectFactory.PreInstantiateSingletons"/>
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);
}

View File

@@ -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);
}

View File

@@ -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}' " +

View File

@@ -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
/// <returns>A reference to another object in the factory.</returns>
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}'.",

View File

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

View File

@@ -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
{
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
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);
}

View File

@@ -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
{
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
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,

View File

@@ -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
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
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}]",

View File

@@ -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";
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
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.",

View File

@@ -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,

View File

@@ -17,6 +17,7 @@
using System.ComponentModel;
using System.Reflection;
using System.Text;
using Spring.Core;
using Spring.Expressions;
using Spring.Expressions.Parser.antlr;

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -50,7 +50,7 @@ namespace Spring.Proxy
#region Fields
/// <summary>
/// The shared <see cref="Common.Logging.ILog"/> instance for this class (and derived classes).
/// The shared <see cref="ILog"/> instance for this class (and derived classes).
/// </summary>
protected static readonly ILog log = LogManager.GetLogger(typeof(AbstractProxyTypeBuilder));

View File

@@ -19,6 +19,8 @@
#endregion
using System.Reflection;
using Spring.Util;
namespace Spring.Reflection.Dynamic

Some files were not shown because too many files have changed in this diff Show More