Inline logger helpers for idiomatic usage (#270)

This commit is contained in:
Marko Lahma
2025-03-28 20:01:17 +02:00
committed by GitHub
parent fda46d95b1
commit 67cd5b83a9
212 changed files with 1142 additions and 1111 deletions

View File

@@ -37,7 +37,7 @@ partial class Build : NukeBuild
readonly bool BuildEms = false;
[Parameter("Version")]
readonly string ProjectVersion = "3.0.2";
readonly string ProjectVersion = "3.1.0";
[Solution] readonly Solution Solution;
[GitRepository] readonly GitRepository GitRepository;

View File

@@ -33,7 +33,7 @@ namespace Spring.Northwind.Service
public void ShipOrder(Order order)
{
log.Info("Shipping order id = " + order.Id);
log.LogInformation("Shipping order id = {OrderId} ", order.Id);
}
}
}

View File

@@ -90,13 +90,13 @@ namespace Spring.Northwind.Service
{
if (order.ShippedDate.HasValue)
{
log.Warn("Order with " + order.Id + " has already been shipped, skipping.");
log.LogWarning("Order {OrderId} has already been shipped, skipping.", order.Id);
continue;
}
//Validate Order
Validate(order);
log.Info("Order " + order.Id + " validated, proceeding with shipping..");
log.LogInformation("Order {OrderId} validated, proceeding with shipping..", order.Id);
//Ship with external shipping service
ShippingService.ShipOrder(order);

View File

@@ -67,18 +67,16 @@ namespace Spring.IocQuickStart.MovieFinder
MovieLister lister = (MovieLister) ctx.GetObject("MyMovieLister");
Movie[] movies = lister.MoviesDirectedBy("Roberto Benigni");
LOG.Debug("Searching for movie...");
LOG.LogDebug("Searching for movie...");
foreach (Movie movie in movies)
{
LOG.Debug(
string.Format("Movie Title = '{0}', Director = '{1}'.",
movie.Title, movie.Director));
LOG.LogDebug("Movie Title = '{Title}', Director = '{Director}'.", movie.Title, movie.Director);
}
LOG.Debug("MovieApp Done.");
LOG.LogDebug("MovieApp Done.");
}
catch (Exception e)
{
LOG.Error("Movie Finder is broken.", e);
LOG.LogError("Movie Finder is broken.", e);
}
finally
{

View File

@@ -23,7 +23,7 @@ namespace Spring.MsmqQuickStart.Client.Handlers
public void Handle(string data)
{
log.Info(string.Format("Received market data. " + data));
log.LogInformation("Received market data. " + data);
// forward to controller to update view
stockController.UpdateMarketData(data);
@@ -33,13 +33,13 @@ namespace Spring.MsmqQuickStart.Client.Handlers
public void Handle(TradeResponse tradeResponse)
{
log.Info(string.Format("Received trade resonse. Ticker = {0}, Price = {1}", tradeResponse.Ticker, tradeResponse.Price));
log.LogInformation("Received trade resonse. Ticker = {TradeResponseTicker}, Price = {TradeResponsePrice}", tradeResponse.Ticker, tradeResponse.Price);
stockController.UpdateTrade(tradeResponse);
}
public void Handle(object catchAllObject)
{
log.Error("could not handle object of type = " + catchAllObject.GetType());
log.LogError("could not handle object of type {ObjectType}", catchAllObject.GetType());
}
}
}

View File

@@ -22,7 +22,7 @@ namespace Spring.MsmqQuickStart.Client
{
try
{
log.Info("Running....");
log.LogInformation("Running....");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (IApplicationContext ctx = ContextRegistry.GetContext())
@@ -34,13 +34,13 @@ namespace Spring.MsmqQuickStart.Client
}
catch (Exception e)
{
log.Error("Spring.MsmqQuickStart.Client is broken.", e);
log.LogError(e, "Spring.MsmqQuickStart.Client is broken.");
}
}
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

@@ -34,7 +34,7 @@ namespace Spring.MsmqQuickStart.Client.UI
//Instead a hardcoded trade request is created in the controller.
tradeRequestStatusTextBox.Text = "Request Pending...";
stockController.SendTradeRequest();
log.Info("Sent trade request.");
log.LogInformation("Sent trade request.");
}
public void UpdateTrade(TradeResponse trade)

View File

@@ -29,9 +29,9 @@ namespace Spring.MsmqQuickStart.Server.Gateways
while (true)
{
string data = GenerateFakeMarketData();
log.Info("Sending market data.");
log.LogInformation("Sending market data.");
MessageQueueTemplate.ConvertAndSend(data);
log.Info("Sleeping " + sleepTimeInSeconds + " seconds before sending more market data.");
log.LogInformation("Sleeping {SleepTimeSeconds} seconds before sending more market data.", sleepTimeInSeconds);
Thread.Sleep(sleepTimeInSeconds);
}
}
@@ -59,4 +59,4 @@ namespace Spring.MsmqQuickStart.Server.Gateways
//y2 = x2 * w;
}
}
}
}

View File

@@ -26,7 +26,7 @@ namespace Spring.MsmqQuickStart.Server.Handlers
public TradeResponse Handle(TradeRequest tradeRequest)
{
log.Info("received trade request - sleeping 2s to simulate long-running task");
log.LogInformation("received trade request - sleeping 2s to simulate long-running task");
TradeResponse tradeResponse;
ArrayList errors = new ArrayList();
if (creditCheckService.CanExecute(tradeRequest, errors))

View File

@@ -44,7 +44,7 @@ namespace Spring.NmsQuickStart.Client.Handlers
public void Handle(Hashtable data)
{
log.Info(string.Format("Received market data. Ticker = {0}, Price = {1}", data["TICKER"], data["PRICE"]));
log.LogInformation("Received market data. Ticker = {Ticker}, Price = {Price}", data["TICKER"], data["PRICE"]);
// forward to controller to update view
stockController.UpdateMarketData(data);
@@ -54,13 +54,13 @@ namespace Spring.NmsQuickStart.Client.Handlers
public void Handle(TradeResponse tradeResponse)
{
log.Info(string.Format("Received trade resonse. Ticker = {0}, Price = {1}", tradeResponse.Ticker, tradeResponse.Price));
log.LogInformation("Received trade response. Ticker = {TradeResponseTicker}, Price = {TradeResponsePrice}", tradeResponse.Ticker, tradeResponse.Price);
stockController.UpdateTrade(tradeResponse);
}
public void Handle(object catchAllObject)
{
log.Error("could not handle object of type = " + catchAllObject.GetType());
log.LogError("could not handle object of type = {ObjectType}", catchAllObject.GetType());
}
}
}

View File

@@ -55,7 +55,7 @@ namespace Spring.NmsQuickStart.Client.UI
//Instead a hardcoded trade request is created in the controller.
tradeRequestStatusTextBox.Text = "Request Pending...";
stockController.SendTradeRequest();
log.Info("Sent trade request.");
log.LogInformation("Sent trade request.");
}
public void UpdateTrade(TradeResponse trade)

View File

@@ -29,9 +29,9 @@ namespace Spring.NmsQuickStart.Server.Gateways
while (true)
{
IDictionary data = GenerateFakeMarketData();
log.Info("Sending market data.");
log.LogInformation("Sending market data.");
NmsTemplate.ConvertAndSend(data);
log.Info("Sleeping " + sleepTimeInSeconds + " seconds before sending more market data.");
log.LogInformation("Sleeping {SleepTimeInSeconds} seconds before sending more market data.", sleepTimeInSeconds);
Thread.Sleep(sleepTimeInSeconds);
}
}

View File

@@ -14,7 +14,6 @@
<DefineConstants>TRACE;DEBUG;NET_4_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -23,7 +22,6 @@
<DefineConstants>TRACE;NET_4_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

View File

@@ -165,7 +165,7 @@ namespace Spring.Aop.Framework.Adapter
if(log.IsEnabled(LogLevel.Debug))
{
log.Debug("Found exception handler method: " + method);
log.LogDebug("Found exception handler method: " + method);
}
#endregion
@@ -266,7 +266,7 @@ namespace Spring.Aop.Framework.Adapter
if(log.IsEnabled(LogLevel.Debug))
{
log.Debug("Trying to find handler for exception of type [" + exception.GetType().Name + "].");
log.LogDebug("Trying to find handler for exception of type [" + exception.GetType().Name + "].");
}
#endregion

View File

@@ -185,7 +185,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Information))
{
logger.Info($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
logger.LogInformation($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
}
eligibleAdvisors.Add(candidate);
}
@@ -200,7 +200,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Information))
{
logger.Info($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
logger.LogInformation($"Candidate advisor [{candidate}] accepted for targetType [{targetType}]");
}
eligibleAdvisors.Add(candidate);
}
@@ -208,7 +208,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Information))
{
logger.Info($"Candidate advisor [{candidate}] rejected for targetType [{targetType}]");
logger.LogInformation($"Candidate advisor [{candidate}] rejected for targetType [{targetType}]");
}
}
}

View File

@@ -238,7 +238,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
logger.LogDebug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
}
nonAdvisedObjects.Add(cacheKey);
@@ -249,7 +249,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Skipping type [{0}]", objectType));
logger.LogDebug(string.Format("Skipping type [{0}]", objectType));
}
nonAdvisedObjects.Add(cacheKey);
@@ -390,7 +390,7 @@ namespace Spring.Aop.Framework.AutoProxy
// found a match
if (logger.IsEnabled(LogLevel.Information))
{
logger.Info(string.Format("TargetSourceCreator [{0} found custom TargetSource for object with objectName '{1}'", tsc, name));
logger.LogInformation(string.Format("TargetSourceCreator [{0} found custom TargetSource for object with objectName '{1}'", tsc, name));
}
return ts;
}
@@ -514,7 +514,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Count : 0;
int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Count : 0;
logger.Info(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", targetName, nrOfCommonInterceptors, nrOfSpecificInterceptors));
logger.LogInformation(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", targetName, nrOfCommonInterceptors, nrOfSpecificInterceptors));
}
@@ -576,7 +576,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
logger.LogDebug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
}
nonAdvisedObjects.Add(cacheKey);
@@ -587,7 +587,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Skipping type [{0}]", objectType));
logger.LogDebug(string.Format("Skipping type [{0}]", objectType));
}
nonAdvisedObjects.Add(cacheKey);

View File

@@ -90,7 +90,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (_log.IsEnabled(LogLevel.Debug))
{
_log.Debug(string.Format("Ignoring currently created advisor '{0}': exception message = {1}",
_log.LogDebug(string.Format("Ignoring currently created advisor '{0}': exception message = {1}",
name, ex.Message));
}
continue;

View File

@@ -63,14 +63,14 @@ namespace Spring.Aop.Framework.AutoProxy.Target
if (!(factory is IObjectDefinitionRegistry))
{
if (logger.IsEnabled(LogLevel.Warning))
logger.Warn("Cannot do autopooling with a IObjectFactory that doesn't implement IObjectDefinitionRegistry");
logger.LogWarning("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.IsEnabled(LogLevel.Information))
logger.Info("Configuring AbstractPrototypeBasedTargetSource...");
logger.LogInformation("Configuring AbstractPrototypeBasedTargetSource...");
// Infinite cycle will result if we don't use a different factory,
// because a GetObject() call with this objectName will go through the autoproxy

View File

@@ -367,8 +367,8 @@ namespace Spring.Aop.Framework
if (targetName == null)
{
logger.Warn("Using non-singleton proxies with singleton targets is often undesirable. " +
"Enable prototype proxies by setting the 'targetName' property.");
logger.LogWarning("Using non-singleton proxies with singleton targets is often undesirable. " +
"Enable prototype proxies by setting the 'targetName' property.");
}
return NewPrototypeInstance();
}
@@ -442,7 +442,7 @@ namespace Spring.Aop.Framework
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Creating copy of prototype ProxyFactoryObject config: " + this);
logger.LogDebug("Creating copy of prototype ProxyFactoryObject config: " + this);
}
// The copy needs a fresh advisor chain, and a fresh TargetSource.
@@ -454,7 +454,7 @@ namespace Spring.Aop.Framework
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Using ProxyConfig: " + copy);
logger.LogDebug("Using ProxyConfig: " + copy);
}
object generatedProxy = copy.CreateAopProxy().GetProxy();
@@ -469,7 +469,7 @@ namespace Spring.Aop.Framework
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Initialize: begin configure target, interceptors and introductions for {0}[{1}]", GetType().Name, GetHashCode()));
logger.LogDebug(string.Format("Initialize: begin configure target, interceptors and introductions for {0}[{1}]", GetType().Name, GetHashCode()));
}
InitializeAdvisorChain();
@@ -477,7 +477,7 @@ namespace Spring.Aop.Framework
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Initialize: completed configuration for {0}[{1}]: {2}", GetType().Name, GetHashCode(), ToProxyConfigString()));
logger.LogDebug(string.Format("Initialize: completed configuration for {0}[{1}]: {2}", GetType().Name, GetHashCode(), ToProxyConfigString()));
}
}
@@ -523,7 +523,7 @@ namespace Spring.Aop.Framework
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Adding global advisor '" + name + "'");
logger.LogDebug("Adding global advisor '" + name + "'");
}
AddGlobalAdvisor(lof, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
@@ -532,7 +532,7 @@ namespace Spring.Aop.Framework
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("resolving advisor name " + "'" + name + "'");
logger.LogDebug("resolving advisor name " + "'" + name + "'");
}
// If we get here, we need to add a named interceptor.
@@ -558,7 +558,7 @@ namespace Spring.Aop.Framework
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Adding advisor list '{0}'", name));
logger.LogDebug(string.Format("Adding advisor list '{0}'", name));
}
IAdvisors advisors = (IAdvisors)advice;
@@ -566,7 +566,7 @@ namespace Spring.Aop.Framework
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, element.GetType().FullName));
logger.LogDebug(string.Format("Adding advisor '{0}' of type {1}", name, element.GetType().FullName));
}
IAdvisor advisor = NamedObjectToAdvisor(element);
@@ -577,7 +577,7 @@ namespace Spring.Aop.Framework
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, advice.GetType().FullName));
logger.LogDebug(string.Format("Adding advisor '{0}' of type {1}", name, advice.GetType().FullName));
}
IAdvisor advisor = NamedObjectToAdvisor(advice);
@@ -679,7 +679,7 @@ namespace Spring.Aop.Framework
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Adding introduction '" + name + "'");
logger.LogDebug("Adding introduction '" + name + "'");
}
if (name.EndsWith(GlobalInterceptorSuffix))
@@ -783,7 +783,7 @@ namespace Spring.Aop.Framework
/// <param name="name">object name from which we obtained this object in our owning object factory</param>
private void AddIntroductionOnChainCreation(object introduction, string name)
{
logger.Debug($"Adding introduction with name '{name}'");
logger.LogDebug($"Adding introduction with name '{name}'");
IIntroductionAdvisor advisor = NamedObjectToIntroduction(introduction);
AddIntroduction(advisor);
}
@@ -797,7 +797,7 @@ namespace Spring.Aop.Framework
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Not Refreshing TargetSource: No target name specified");
logger.LogDebug("Not Refreshing TargetSource: No target name specified");
}
return TargetSource;
@@ -807,7 +807,7 @@ namespace Spring.Aop.Framework
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Refreshing TargetSource with name '" + targetName + "'");
logger.LogDebug("Refreshing TargetSource with name '" + targetName + "'");
}
object target = objectFactory.GetObject(targetName);
@@ -830,7 +830,7 @@ namespace Spring.Aop.Framework
PrototypePlaceholder pa = (PrototypePlaceholder)advisor;
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
logger.LogDebug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
}
AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory");
@@ -862,7 +862,7 @@ namespace Spring.Aop.Framework
PrototypePlaceholder pa = (PrototypePlaceholder)introduction;
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
logger.LogDebug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
}
AssertUtils.ArgumentNotNull(objectFactory, "ObjectFactory");
@@ -934,7 +934,7 @@ namespace Spring.Aop.Framework
/// </remarks>
protected override void InterfacesChanged()
{
logger.Info("Implemented interfaces have changed; reseting singleton instance");
logger.LogInformation("Implemented interfaces have changed; reseting singleton instance");
singletonInstance = null;
base.InterfacesChanged();
}
@@ -967,7 +967,7 @@ namespace Spring.Aop.Framework
targetName = finalName;
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));
logger.LogDebug(string.Format("Object with name '{0}' concluding interceptor chain is not an advisor class: treating it as a target or TargetSource", finalName));
}
String[] newNames = new String[interceptorNames.Length - 1];
Array.Copy(interceptorNames, 0, newNames, 0, newNames.Length);

View File

@@ -160,8 +160,8 @@ namespace Spring.Aop.Support
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.Debug("Candidate is: '" + pattern + "'; pattern is '" +
_compiledPatterns[patternIndex].ToString() + "'; matched=" + matched);
_logger.LogDebug("Candidate is: '" + pattern + "'; pattern is '" +
_compiledPatterns[patternIndex].ToString() + "'; matched=" + matched);
}
return matched;

View File

@@ -138,9 +138,9 @@ namespace Spring.Aop.Target
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format(
"Getting object with name '{0}' to determine class.",
TargetObjectName));
logger.LogDebug(string.Format(
"Getting object with name '{0}' to determine class.",
TargetObjectName));
}
#endregion
@@ -162,9 +162,9 @@ namespace Spring.Aop.Target
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format(
"Creating new target from object '{0}'.",
TargetObjectName));
logger.LogDebug(string.Format(
"Creating new target from object '{0}'.",
TargetObjectName));
}
#endregion

View File

@@ -69,7 +69,7 @@ namespace Spring.Aop.Target
if(logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Creating object pool.");
logger.LogDebug("Creating object pool.");
}
#endregion
@@ -138,7 +138,7 @@ namespace Spring.Aop.Target
if(logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Closing pool...");
logger.LogDebug("Closing pool...");
}
#endregion

View File

@@ -148,10 +148,10 @@ namespace Spring.Aop.Target
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format(
"No target for apartment prototype '{0}' " +
"found in thread: creating one and binding it to thread '#{1}'",
TargetObjectName, Thread.CurrentThread.GetHashCode()));
logger.LogDebug(string.Format(
"No target for apartment prototype '{0}' " +
"found in thread: creating one and binding it to thread '#{1}'",
TargetObjectName, Thread.CurrentThread.GetHashCode()));
}
#endregion
@@ -187,7 +187,7 @@ namespace Spring.Aop.Target
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Destroying ThreadLocal bindings");
logger.LogDebug("Destroying ThreadLocal bindings");
}
#endregion
@@ -205,12 +205,13 @@ namespace Spring.Aop.Target
#region Instrumentation
if (logger.IsEnabled(LogLevel.Warning))
{
logger.Warn(string.Format(
"Thread-bound target of class '{0}' " +
"threw exception from it's IDisposable.Dispose() method.",
target.GetType()), ex);
}
{
string message = string.Format(
"Thread-bound target of class '{0}' " +
"threw exception from it's IDisposable.Dispose() method.",
target.GetType());
logger.LogWarning(ex, message);
}
#endregion
}

View File

@@ -19,6 +19,7 @@
#endregion
using System.Collections;
using Microsoft.Extensions.Logging;
using Spring.Expressions;
namespace Spring.Aspects
@@ -155,11 +156,13 @@ namespace Spring.Aspects
canProcess = (bool) expression.GetValue(null, callContextDictionary);
} catch (InvalidCastException e)
{
log.Warn("Was not able to unbox constraint expression to boolean [" + ConstraintExpressionText + "]", e);
string message = "Was not able to unbox constraint expression to boolean [" + ConstraintExpressionText + "]";
log.LogWarning(e, message);
return false;
} catch (Exception e)
{
log.Warn("Was not able to evaluate constraint expression [" + ConstraintExpressionText + "]",e);
string message = "Was not able to evaluate constraint expression [" + ConstraintExpressionText + "]";
log.LogWarning(e, message);
return false;
}
return canProcess;

View File

@@ -139,7 +139,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(string.Format("Caching parameter for key [{0}] into cache [{1}].", key, paramInfo.CacheName));
logger.LogDebug(string.Format("Caching parameter for key [{0}] into cache [{1}].", key, paramInfo.CacheName));
}
#endregion

View File

@@ -199,7 +199,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(String.Format("Object for key [{0}] was of type [{1}] which is not compatible with return type [{2}]. Proceeding...", resultKey, returnValue.GetType(), returnType));
logger.LogDebug(String.Format("Object for key [{0}] was of type [{1}] which is not compatible with return type [{2}]. Proceeding...", resultKey, returnValue.GetType(), returnType));
}
#endregion
@@ -212,7 +212,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(String.Format("Object for key [{0}] was not found in cache [{1}]. Proceeding...", resultKey, resultInfo.CacheName));
logger.LogDebug(String.Format("Object for key [{0}] was not found in cache [{1}]. Proceeding...", resultKey, resultInfo.CacheName));
}
#endregion
@@ -222,7 +222,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(String.Format("Caching object for key [{0}] into cache [{1}].", resultKey, resultInfo.CacheName));
logger.LogDebug(String.Format("Caching object for key [{0}] into cache [{1}].", resultKey, resultInfo.CacheName));
}
#endregion
cache.Insert(resultKey, (returnValue == null) ? NullValue : returnValue, resultInfo.TimeToLiveTimeSpan);
@@ -233,7 +233,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(String.Format("Object for key [{0}] found in cache [{1}]. Aborting invocation...", resultKey, resultInfo.CacheName));
logger.LogDebug(String.Format("Object for key [{0}] found in cache [{1}]. Aborting invocation...", resultKey, resultInfo.CacheName));
}
#endregion
}
@@ -277,7 +277,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isDebugEnabled)
{
logger.Debug("Caching collection item for key [" + itemKey + "].");
logger.LogDebug("Caching collection item for key [" + itemKey + "].");
}
#endregion
cache.Insert(itemKey, (item == null ? NullValue : item), itemInfo.TimeToLiveTimeSpan);

View File

@@ -117,7 +117,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(string.Format("Removing objects for keys [{0}] from cache [{1}].", keys, cacheInfo.CacheName));
logger.LogDebug(string.Format("Removing objects for keys [{0}] from cache [{1}].", keys, cacheInfo.CacheName));
}
#endregion
cache.RemoveAll((ICollection) keys);
@@ -127,7 +127,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(string.Format("Removing object for key [{0}] from cache [{1}].", keys, cacheInfo.CacheName));
logger.LogDebug(string.Format("Removing object for key [{0}] from cache [{1}].", keys, cacheInfo.CacheName));
}
#endregion
cache.Remove(keys);
@@ -138,7 +138,7 @@ namespace Spring.Aspects.Cache
#region Instrumentation
if (isLogDebugEnabled)
{
logger.Debug(string.Format("Invalidate cache [{0}].", cacheInfo.CacheName));
logger.LogDebug(string.Format("Invalidate cache [{0}].", cacheInfo.CacheName));
}
#endregion
cache.Clear();

View File

@@ -22,8 +22,7 @@ using System.Collections;
using System.Reflection;
using AopAlliance.Intercept;
using Microsoft.Extensions.Logging;
using Spring.Util;
namespace Spring.Aspects.Exceptions
@@ -321,7 +320,7 @@ namespace Spring.Aspects.Exceptions
if (!parsedAdviceExpression.Success)
{
log.Warn("Could not parse exception hander statement " + handlerString);
log.LogWarning("Could not parse exception hander statement " + handlerString);
return null;
}
@@ -450,7 +449,7 @@ namespace Spring.Aspects.Exceptions
}
else
{
log.Warn("Could not parse exception hander statement " + parsedAdviceExpression.AdviceExpression);
log.LogWarning("Could not parse exception hander statement " + parsedAdviceExpression.AdviceExpression);
}
return null;
}

View File

@@ -1,3 +1,4 @@
using Microsoft.Extensions.Logging;
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -36,7 +37,8 @@ namespace Spring.Aspects.Exceptions
}
catch (Exception e)
{
log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
string message = "Was not able to evaluate action expression [" + ActionExpressionText + "]";
log.LogWarning(e, message);
}
return null;
}

View File

@@ -142,7 +142,8 @@ namespace Spring.Aspects.Exceptions
}
catch (Exception e)
{
log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
string message = "Was not able to evaluate action expression [" + ActionExpressionText + "]";
log.LogWarning(e, message);
}
return "logged";
}

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -60,7 +61,8 @@ namespace Spring.Aspects.Exceptions
}
catch (Exception e)
{
log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
string message = "Was not able to evaluate action expression [" + ActionExpressionText + "]";
log.LogWarning(e, message);
}
return returnVal;
}

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -58,7 +59,8 @@ namespace Spring.Aspects.Exceptions
}
catch (Exception e)
{
log.Warn("Was not able to evaluate action expression [" + ActionExpressionText + "]", e);
string message = "Was not able to evaluate action expression [" + ActionExpressionText + "]";
log.LogWarning(e, message);
}
Exception translatedException = o as Exception;
if (translatedException != null)

View File

@@ -420,19 +420,19 @@ namespace Spring.Aspects.Logging
case LogLevel.Trace:
if (log.IsEnabled(LogLevel.Trace))
{
if (e == null) log.Trace(text); else log.LogTrace(e, text);
if (e == null) log.LogTrace(text); else log.LogTrace(e, text);
}
break;
case LogLevel.Debug:
if (log.IsEnabled(LogLevel.Debug))
{
if (e == null) log.Debug(text); else log.Debug(text, e);
if (e == null) log.LogDebug(text); else log.LogDebug(e, text);
}
break;
case LogLevel.Error:
if (log.IsEnabled(LogLevel.Error))
{
if (e == null) log.Error(text); else log.Error(text, e);
if (e == null) log.LogError(text); else log.LogError(e, text);
}
break;
case LogLevel.Critical:
@@ -444,13 +444,13 @@ namespace Spring.Aspects.Logging
case LogLevel.Information:
if (log.IsEnabled(LogLevel.Information))
{
if (e == null) log.Info(text); else log.LogInformation(e, text);
if (e == null) log.LogInformation(text); else log.LogInformation(e, text);
}
break;
case LogLevel.Warning:
if (log.IsEnabled(LogLevel.Warning))
{
if (e == null) log.Warn(text); else log.LogWarning(e, text);
if (e == null) log.LogWarning(text); else log.LogWarning(e, text);
}
break;
case LogLevel.None:

View File

@@ -175,7 +175,7 @@ namespace Spring.Aspects
{
if (log.IsEnabled(LogLevel.Trace))
{
log.Trace("Retrying " + invocation.Method.Name);
log.LogTrace("Retrying " + invocation.Method.Name);
}
callContextDictionary["n"] = numAttempts;
Sleep(retryExceptionHandler, callContextDictionary, sleepHandler);
@@ -189,7 +189,7 @@ namespace Spring.Aspects
} while (numAttempts <= retryExceptionHandler.MaximumRetryCount);
log.Debug("Invoked successfully after " + numAttempts + " attempt(s)");
log.LogDebug("Invoked successfully after " + numAttempts + " attempt(s)");
return returnVal;
}
@@ -212,12 +212,14 @@ namespace Spring.Aspects
}
catch (InvalidCastException e)
{
log.Warn("Was not able to cast expression to decimal [" + handler.DelayRateExpression + "]. Sleeping for 1 second", e);
string message = "Was not able to cast expression to decimal [" + handler.DelayRateExpression + "]. Sleeping for 1 second";
log.LogWarning(e, message);
sleepHandler(new TimeSpan(0,0,1));
}
catch (Exception e)
{
log.Warn("Was not able to evaluate rate expression [" + handler.DelayRateExpression + "]. Sleeping for 1 second", e);
string message = "Was not able to evaluate rate expression [" + handler.DelayRateExpression + "]. Sleeping for 1 second";
log.LogWarning(e, message);
sleepHandler(new TimeSpan(0,0,1));
}
}
@@ -281,7 +283,7 @@ namespace Spring.Aspects
if (!parsedAdviceExpression.Success)
{
log.Warn("Could not parse retry expression " + retryExpressionString);
log.LogWarning("Could not parse retry expression " + retryExpressionString);
return null;
}
@@ -302,7 +304,7 @@ namespace Spring.Aspects
handler.DelayTimeSpan = (TimeSpan) timeSpanConverter.ConvertFrom(null, null, ts);
} catch (Exception)
{
log.Warn("Could not parse timespan " + match.Groups[3].Value.Trim());
log.LogWarning("Could not parse timespan " + match.Groups[3].Value.Trim());
return null;
}
return handler;

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
using Spring.Core.TypeResolution;
namespace Spring.Context.Attributes.TypeFilters
@@ -58,7 +59,7 @@ namespace Spring.Context.Attributes.TypeFilters
catch (Exception)
{
RequiredType = null;
Logger.Error("Can't load type defined in expression:" + typeToLoad);
Logger.LogError("Can't load type defined in expression:" + typeToLoad);
}
}

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
using Spring.Core.TypeResolution;
using Spring.Util;
using Spring.Objects.Factory.Support;
@@ -65,7 +66,7 @@ namespace Spring.Context.Attributes.TypeFilters
}
catch
{
Logger.Error(string.Format("Can't instatiate {0}. Type needs to have a non arg constructor.", expression));
Logger.LogError(string.Format("Can't instatiate {0}. Type needs to have a non arg constructor.", expression));
}
return null;
@@ -80,7 +81,7 @@ namespace Spring.Context.Attributes.TypeFilters
}
catch (Exception)
{
Logger.Error("Can't load type defined in exoression:" + typeToLoad);
Logger.LogError("Can't load type defined in exoression:" + typeToLoad);
}
return null;

View File

@@ -103,7 +103,7 @@ namespace Spring.Context.Config
foreach (var baseAssembly in baseAssemblies.Split(','))
{
if (Logger.IsEnabled(LogLevel.Debug))
Logger.Debug("Start With Assembly Filter: " + baseAssembly);
Logger.LogDebug("Start With Assembly Filter: " + baseAssembly);
scanner.WithAssemblyFilter(assy => assy.FullName.StartsWith(baseAssembly));
}

View File

@@ -241,10 +241,10 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
CultureInfo.InvariantCulture,
"Closing application context [{0}].",
Name));
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Closing application context [{0}].",
Name));
}
// Closed event is raised before destroying objectfactory to enable registered IApplicationEventListeners
@@ -587,7 +587,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"processed {factoryProcessorNames.Count} IFactoryObjectPostProcessors defined in application context [{Name}].");
log.LogDebug($"processed {factoryProcessorNames.Count} IFactoryObjectPostProcessors defined in application context [{Name}].");
}
}
@@ -648,8 +648,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
$"processed {objectProcessors.Count} IObjectPostProcessors defined in application context [{Name}].");
log.LogDebug($"processed {objectProcessors.Count} IObjectPostProcessors defined in application context [{Name}].");
}
}
@@ -679,8 +678,8 @@ namespace Spring.Context.Support
{
_eventRegistry = (IEventRegistry)candidateRegistry;
log.Debug(StringUtils.Surround(
"Using IEventRegistry [", EventRegistry, "]"));
log.LogDebug(StringUtils.Surround(
"Using IEventRegistry [", EventRegistry, "]"));
}
else
{
@@ -688,11 +687,11 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn(string.Format(
"Found object in context named '{0}' : this name " +
"is typically reserved for IEventRegistry objects. " +
"Falling back to default '{1}'.",
EventRegistryObjectName, EventRegistry));
log.LogWarning(string.Format(
"Found object in context named '{0}' : this name " +
"is typically reserved for IEventRegistry objects. " +
"Falling back to default '{1}'.",
EventRegistryObjectName, EventRegistry));
}
}
}
@@ -702,8 +701,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
$"No IEventRegistry found with name '{EventRegistryObjectName}' : using default '{EventRegistry}'.");
log.LogDebug($"No IEventRegistry found with name '{EventRegistryObjectName}' : using default '{EventRegistry}'.");
}
}
var interestedParties = GetObjects<IEventRegistryAware>(true, false).Values;
@@ -765,8 +763,8 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(StringUtils.Surround(
"Using MessageSource [", MessageSource, "]"));
log.LogDebug(StringUtils.Surround(
"Using MessageSource [", MessageSource, "]"));
}
}
else
@@ -776,11 +774,11 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn(string.Format(
"Found object in context named '{0}' : this name " +
"is typically reserved for IMessageSource objects. " +
"Falling back to default '{1}'.",
MessageSourceObjectName, MessageSource));
log.LogWarning(string.Format(
"Found object in context named '{0}' : this name " +
"is typically reserved for IMessageSource objects. " +
"Falling back to default '{1}'.",
MessageSourceObjectName, MessageSource));
}
}
}
@@ -792,9 +790,9 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
"No message source found in the current context: using parent context's message source '{0}'.",
MessageSource));
log.LogDebug(string.Format(
"No message source found in the current context: using parent context's message source '{0}'.",
MessageSource));
}
}
else
@@ -804,9 +802,9 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
"No IMessageSource found with name '{0}' : using default '{1}'.",
MessageSourceObjectName, MessageSource));
log.LogDebug(string.Format(
"No IMessageSource found with name '{0}' : using default '{1}'.",
MessageSourceObjectName, MessageSource));
}
}
}
@@ -859,7 +857,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("ApplicationContext Refresh: Refreshing object factory "));
log.LogDebug(string.Format("ApplicationContext Refresh: Refreshing object factory "));
}
RefreshObjectFactory();
@@ -868,35 +866,35 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("ApplicationContext Refresh: Registering well-known processors and objects"));
log.LogDebug(string.Format("ApplicationContext Refresh: Registering well-known processors and objects"));
}
PrepareObjectFactory(objectFactory);
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("ApplicationContext Refresh: Custom post processing object factory"));
log.LogDebug(string.Format("ApplicationContext Refresh: Custom post processing object factory"));
}
PostProcessObjectFactory(objectFactory);
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("ApplicationContext Refresh: Post processing object factory using pre-registered processors"));
log.LogDebug(string.Format("ApplicationContext Refresh: Post processing object factory using pre-registered processors"));
}
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
CultureInfo.InvariantCulture,
"{0} objects defined in application context [{1}].",
ObjectDefinitionCount == 0 ? "No" : ObjectDefinitionCount.ToString(),
Name));
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"{0} objects defined in application context [{1}].",
ObjectDefinitionCount == 0 ? "No" : ObjectDefinitionCount.ToString(),
Name));
}
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("ApplicationContext Refresh: Post processing object factory using defined processors"));
log.LogDebug(string.Format("ApplicationContext Refresh: Post processing object factory using defined processors"));
}
InvokeObjectFactoryPostProcessors(objectFactory);
@@ -911,7 +909,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("ApplicationContext Refresh: Preinstantiating singletons"));
log.LogDebug(string.Format("ApplicationContext Refresh: Preinstantiating singletons"));
}
objectFactory.PreInstantiateSingletons();
@@ -920,7 +918,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Information))
{
log.Info(string.Format("ApplicationContext Refresh: Completed"));
log.LogInformation(string.Format("ApplicationContext Refresh: Completed"));
}
}
}
@@ -2338,10 +2336,10 @@ namespace Spring.Context.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
CultureInfo.InvariantCulture,
"Publishing event in context [{0}] : {1}",
Name, e));
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Publishing event in context [{0}] : {1}",
Name, e));
}
OnContextEvent(sender, e);
@@ -2375,9 +2373,9 @@ namespace Spring.Context.Support
{
if (log.IsEnabled(LogLevel.Information))
{
log.Info(string.Format(
"Object '{0}' is not eligible for being processed by all " +
"IObjectPostProcessors (for example: not eligible for auto-proxying).", objectName));
log.LogInformation(string.Format(
"Object '{0}' is not eligible for being processed by all " +
"IObjectPostProcessors (for example: not eligible for auto-proxying).", objectName));
}
}
return obj;

View File

@@ -148,10 +148,9 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Refreshed ObjectFactory for application context '{0}'.",
Name));
log.LogDebug(string.Format(
"Refreshed ObjectFactory for application context '{0}'.",
Name));
}
#endregion

View File

@@ -264,7 +264,7 @@ namespace Spring.Context.Support
}
#region Instrumentation
if (Log.IsEnabled(LogLevel.Debug)) Log.Debug(string.Format("creating context '{0}'", contextName ) );
if (Log.IsEnabled(LogLevel.Debug)) Log.LogDebug(string.Format("creating context '{0}'", contextName ));
#endregion
IApplicationContext context = null;
@@ -293,7 +293,7 @@ namespace Spring.Context.Support
IList<XmlNode> childContexts = GetChildContexts(contextElement);
CreateChildContexts(context, configContext, childContexts);
if (Log.IsEnabled(LogLevel.Debug)) Log.Debug( string.Format("context '{0}' created for name '{1}'", context, contextName) );
if (Log.IsEnabled(LogLevel.Debug)) Log.LogDebug(string.Format("context '{0}' created for name '{1}'", context, contextName));
}
catch (Exception ex)
{

View File

@@ -174,7 +174,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(String.Format("Registering context '{0}' under name '{1}'.", context, context.Name));
log.LogDebug(String.Format("Registering context '{0}' under name '{1}'.", context, context.Name));
}
#endregion
@@ -290,7 +290,7 @@ namespace Spring.Context.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(String.Format(
log.LogDebug(String.Format(
"Returning context '{0}' registered under name '{1}'.", ctx, name));
}
@@ -326,9 +326,8 @@ namespace Spring.Context.Support
{
if (instance.contextMap.Count > 0)
{
log.Warn(
String.Format(
"Not all contexts were removed from registry during cleanup - did you forget to call base.Dispose() when overriding AbstractApplicationContext.Dispose()?"));
log.LogWarning(String.Format(
"Not all contexts were removed from registry during cleanup - did you forget to call base.Dispose() when overriding AbstractApplicationContext.Dispose()?"));
}
}

View File

@@ -22,6 +22,7 @@
using System.Globalization;
using System.Reflection;
using Microsoft.Extensions.Logging;
#endregion
@@ -129,10 +130,10 @@ namespace Spring.Core.IO
Stream stream = _assembly.GetManifestResourceStream(_resourceName);
if (stream == null)
{
log.Error("Could not load resource with name = [" + _resourceName +
"] from assembly + " + _assembly);
log.Error("URI specified = [" + this._fullResourceName + "] Spring.NET URI syntax is 'assembly://assemblyName/namespace/resourceName'.");
log.Error("Resource name often has the default namespace prefixed, e.g. 'assembly://MyAssembly/MyNamespace/MyNamespace.MyResource.txt'.");
log.LogError("Could not load resource with name = [" + _resourceName +
"] from assembly + " + _assembly);
log.LogError("URI specified = [" + this._fullResourceName + "] Spring.NET URI syntax is 'assembly://assemblyName/namespace/resourceName'.");
log.LogError("Resource name often has the default namespace prefixed, e.g. 'assembly://MyAssembly/MyNamespace/MyNamespace.MyResource.txt'.");
}
return stream;
}

View File

@@ -184,10 +184,10 @@ namespace Spring.Core.IO
if (_log.IsEnabled(LogLevel.Warning))
{
_log.Warn(string.Format(
CultureInfo.InvariantCulture,
"Could not resolve placeholder '{0}' in resource path " +
"'{1}' as an environment variable.", expression, path));
_log.LogWarning(string.Format(
CultureInfo.InvariantCulture,
"Could not resolve placeholder '{0}' in resource path " +
"'{1}' as an environment variable.", expression, path));
}
#endregion

View File

@@ -1,4 +1,5 @@
using System.Reflection;
using Microsoft.Extensions.Logging;
using Spring.Globalization;
using Spring.Validation;
@@ -132,7 +133,7 @@ namespace Spring.DataBinding
}
catch (Exception ex)
{
log.Warn(string.Format("Failed binding[{0}]:{1}", this.Id, ex));
log.LogWarning(string.Format("Failed binding[{0}]:{1}", this.Id, ex));
if (!SetInvalid(validationErrors)) throw;
}
}

View File

@@ -21,6 +21,7 @@
using System.Collections;
using System.Globalization;
using System.Resources;
using Microsoft.Extensions.Logging;
using Spring.Context;
using Spring.Context.Support;
using Spring.Expressions;
@@ -75,7 +76,7 @@ namespace Spring.Globalization.Localizers
catch (MissingManifestResourceException mmrex)
{
// ignore but log missing ResourceSet
log.Debug("No ResourceSet available for invariant culture", mmrex);
log.LogDebug(mmrex, "No ResourceSet available for invariant culture");
}
if (invariantResources != null)

View File

@@ -32,16 +32,3 @@ public static class LogManager
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

@@ -176,8 +176,8 @@ namespace Spring.Objects.Factory.Config
if (_logger.IsEnabled(LogLevel.Warning))
{
_logger.Warn(string.Format(CultureInfo.InvariantCulture,
"Cannot find object '{0}' when overriding properties; check configuration.", name));
_logger.LogWarning(string.Format(CultureInfo.InvariantCulture,
"Cannot find object '{0}' when overriding properties; check configuration.", name));
}
#endregion
@@ -187,8 +187,8 @@ namespace Spring.Objects.Factory.Config
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.Debug(string.Format(CultureInfo.InvariantCulture,
"Property '{0}' set to '{1}'.", key, value));
_logger.LogDebug(string.Format(CultureInfo.InvariantCulture,
"Property '{0}' set to '{1}'.", key, value));
}
#endregion

View File

@@ -304,9 +304,9 @@ namespace Spring.Objects.Factory.Config
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format(
CultureInfo.InvariantCulture,
"Resolving placeholder '{0}' to '{1}'.", placeholder, resolvedValue));
logger.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Resolving placeholder '{0}' to '{1}'.", placeholder, resolvedValue));
}
#endregion

View File

@@ -272,9 +272,9 @@ namespace Spring.Objects.Factory.Config
if (_log.IsEnabled(LogLevel.Debug))
{
_log.Debug(string.Format(
CultureInfo.InvariantCulture,
"Loading configuration from '{0}'.", resource));
_log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Loading configuration from '{0}'.", resource));
}
#endregion
@@ -301,7 +301,7 @@ namespace Spring.Objects.Factory.Config
if (_log.IsEnabled(LogLevel.Warning))
{
_log.Warn(errorMessage);
_log.LogWarning(errorMessage);
}
#endregion

View File

@@ -301,9 +301,9 @@ namespace Spring.Objects.Factory.Config
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug(string.Format(
CultureInfo.InvariantCulture,
"Resolving placeholder '{0}' to '{1}'.", placeholder, resolvedValue));
logger.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Resolving placeholder '{0}' to '{1}'.", placeholder, resolvedValue));
}
if (resolvedValue == null

View File

@@ -33,7 +33,7 @@ namespace Spring.Objects.Factory.Parsing
public void Error(Problem problem)
{
_logger.Error(problem.Message);
_logger.LogError(problem.Message);
throw new ObjectDefinitionParsingException(problem);
}
@@ -45,7 +45,7 @@ namespace Spring.Objects.Factory.Parsing
public void Warning(Problem problem)
{
_logger.Warn(problem.Message);
_logger.LogWarning(problem.Message);
}

View File

@@ -239,7 +239,7 @@ namespace Spring.Objects.Factory.Support
RootObjectDefinition definition = GetMergedObjectDefinition(name, true);
if (definition != null)
{
log.Debug($"configuring object '{instance}' using definition '{name}'");
log.LogDebug($"configuring object '{instance}' using definition '{name}'");
ApplyPropertyValues(name, definition, new ObjectWrapper(instance), definition.PropertyValues);
}
}
@@ -291,8 +291,8 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Invoking IInstantiationAwareObjectPostProcessors before " +
$"the instantiation of '{objectName}'.");
log.LogDebug("Invoking IInstantiationAwareObjectPostProcessors before " +
$"the instantiation of '{objectName}'.");
}
for (var i = 0; i < objectPostProcessors.Count; i++)
@@ -658,19 +658,17 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture,
"Added autowiring by name from object name '{0}' via " + "property '{1}' to object named '{1}'.", name,
propertyName));
log.LogDebug(string.Format(CultureInfo.InvariantCulture,
"Added autowiring by name from object name '{0}' via " + "property '{1}' to object named '{1}'.", name,
propertyName));
}
}
else
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture,
"Not autowiring property '{0}' of object '{1}' by name: " + "no matching object found.", propertyName, name));
log.LogDebug(string.Format(CultureInfo.InvariantCulture,
"Not autowiring property '{0}' of object '{1}' by name: " + "no matching object found.", propertyName, name));
}
}
}
@@ -714,10 +712,9 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture,
"Autowiring by type from object name '{0}' via property " + "'{1}' to object named '{2}'.", name,
propertyName, ObjectUtils.EnumerateFirstElement(matchingObjects.Keys)));
log.LogDebug(string.Format(CultureInfo.InvariantCulture,
"Autowiring by type from object name '{0}' via property " + "'{1}' to object named '{2}'.", name,
propertyName, ObjectUtils.EnumerateFirstElement(matchingObjects.Keys)));
}
}
else if (matchingObjects != null && matchingObjects.Count > 1)
@@ -733,9 +730,8 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture, "Not autowiring property '{0}' of object '{1}': no matching object found.",
propertyName, name));
log.LogDebug(string.Format(CultureInfo.InvariantCulture, "Not autowiring property '{0}' of object '{1}': no matching object found.",
propertyName, name));
}
}
}
@@ -847,7 +843,7 @@ namespace Spring.Objects.Factory.Support
var isDebugEnabled = log.IsEnabled(LogLevel.Debug);
if (isDebugEnabled)
{
log.Debug($"Creating instance of Object '{name}' with merged definition [{definition}].");
log.LogDebug($"Creating instance of Object '{name}' with merged definition [{definition}].");
}
// Make sure object type is actually resolved at this point.
@@ -892,7 +888,7 @@ namespace Spring.Objects.Factory.Support
{
if (isDebugEnabled)
{
log.Debug($"Eagerly caching object '{name}' to allow for resolving potential circular references");
log.LogDebug($"Eagerly caching object '{name}' to allow for resolving potential circular references");
}
AddEagerlyCachedSingleton(name, definition, instance);
eagerlyCached = true;
@@ -1259,7 +1255,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Calling AfterPropertiesSet() on object with name '{0}'.", name));
log.LogDebug(string.Format(CultureInfo.InvariantCulture, "Calling AfterPropertiesSet() on object with name '{0}'.", name));
}
((IInitializingObject)target).AfterPropertiesSet();
@@ -1268,9 +1264,8 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture, "Calling custom init method '{0} on object with name '{1}'.",
definition.InitMethodName, name));
log.LogDebug(string.Format(CultureInfo.InvariantCulture, "Calling custom init method '{0} on object with name '{1}'.",
definition.InitMethodName, name));
}
try
@@ -1328,7 +1323,7 @@ namespace Spring.Objects.Factory.Support
}
if (targetMethod == null)
{
log.Error("Couldn't find a method named '" + destroyMethodName + "' on object with name '" + name + "'");
log.LogError("Couldn't find a method named '" + destroyMethodName + "' on object with name '" + name + "'");
}
else
{
@@ -1339,7 +1334,8 @@ namespace Spring.Objects.Factory.Support
}
catch (TargetInvocationException ex)
{
log.Error("Couldn't invoke destroy method '" + destroyMethodName + "' of object with name '" + name + "'", ex.GetBaseException());
string message = "Couldn't invoke destroy method '" + destroyMethodName + "' of object with name '" + name + "'";
log.LogError(ex.GetBaseException(), message);
}
catch (Exception ex)
{
@@ -1350,9 +1346,8 @@ namespace Spring.Objects.Factory.Support
private void LogExceptionRaisedByCustomDestroyMethodInvocation(string destroyMethodName, string name, Exception ex)
{
log.Error(
string.Format(CultureInfo.InvariantCulture, "Couldn't invoke destroy method '{0}' of object with name '{1}'.", destroyMethodName, name),
ex);
string message = string.Format(CultureInfo.InvariantCulture, "Couldn't invoke destroy method '{0}' of object with name '{1}'.", destroyMethodName, name);
log.LogError(ex, message);
}
/// <summary>
@@ -1631,9 +1626,8 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.",
argumentName, name, reference.ObjectName));
log.LogDebug(string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.",
argumentName, name, reference.ObjectName));
}
try
@@ -1759,7 +1753,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"Configuring object using definition '{name}'");
log.LogDebug($"Configuring object using definition '{name}'");
}
PopulateObject(name, definition, wrapper);
@@ -1769,7 +1763,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"Setting the name property on the IObjectNameAware object '{name}'.");
log.LogDebug($"Setting the name property on the IObjectNameAware object '{name}'.");
}
((IObjectNameAware)instance).ObjectName = name;
@@ -1779,8 +1773,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
$"Setting the ObjectFactory property on the IObjectFactoryAware object '{name}'.");
log.LogDebug($"Setting the ObjectFactory property on the IObjectFactoryAware object '{name}'.");
}
((IObjectFactoryAware)instance).ObjectFactory = this;
@@ -1896,7 +1889,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"Invoking IObjectPostProcessors before initialization of object '{name}'");
log.LogDebug($"Invoking IObjectPostProcessors before initialization of object '{name}'");
}
object result = instance;
@@ -1938,7 +1931,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"Invoking IObjectPostProcessors after initialization of object '{name}'");
log.LogDebug($"Invoking IObjectPostProcessors after initialization of object '{name}'");
}
object result = instance;

View File

@@ -228,7 +228,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Loaded " + loadCount + " object definitions from location [" + location + "]");
log.LogDebug("Loaded " + loadCount + " object definitions from location [" + location + "]");
}
return loadCount;
}

View File

@@ -739,8 +739,8 @@ namespace Spring.Objects.Factory.Support
}
catch (Exception ex)
{
log.Warn("FactoryObject threw exception from ObjectType, despite the contract saying " +
"that it should return null if the type of its object cannot be determined yet", ex);
log.LogWarning(ex, "FactoryObject threw exception from ObjectType, despite the contract saying " +
"that it should return null if the type of its object cannot be determined yet");
return null;
}
}
@@ -774,7 +774,7 @@ namespace Spring.Objects.Factory.Support
catch (ObjectCreationException ex)
{
// Can only happen when getting a FactoryObject.
log.Warn("Ignoring object creation exception on FactoryObject type check", ex);
log.LogWarning(ex, "Ignoring object creation exception on FactoryObject type check");
return null;
}
}
@@ -877,7 +877,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Calling code asked for normal instance for name '{0}'.", canonicalName));
log.LogDebug(string.Format("Calling code asked for normal instance for name '{0}'.", canonicalName));
}
return instance;
@@ -888,9 +888,8 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format("Calling code asked for IFactoryObject instance for name '{0}'.",
TransformedObjectName(name)));
log.LogDebug(string.Format("Calling code asked for IFactoryObject instance for name '{0}'.",
TransformedObjectName(name)));
}
return instance;
@@ -898,7 +897,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Object with name '{0}' is a factory object.", canonicalName));
log.LogDebug(string.Format("Object with name '{0}' is a factory object.", canonicalName));
}
object resultInstance = null;
@@ -912,7 +911,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Dereferencing Object with name '{0}'", canonicalName));
log.LogDebug(string.Format("Dereferencing Object with name '{0}'", canonicalName));
}
// return object instance from factory...
@@ -954,7 +953,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Returning factory product from cache for Object with name '{0}'", canonicalName));
log.LogDebug(string.Format("Returning factory product from cache for Object with name '{0}'", canonicalName));
}
}
return resultInstance;
@@ -1001,7 +1000,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Factory object with name '{0}' is configurable.", TransformedObjectName(objectName)));
log.LogDebug(string.Format("Factory object with name '{0}' is configurable.", TransformedObjectName(objectName)));
}
if (configurableFactory.ProductTemplate != null)
@@ -2107,7 +2106,7 @@ namespace Spring.Objects.Factory.Support
if (isDebugEnabled)
{
log.Debug(string.Format("{2}GetObjectInternal: obtaining instance for name {0} => canonical name {1}", name, objectName, new string(' ', nestingCount * indent)));
log.LogDebug(string.Format("{2}GetObjectInternal: obtaining instance for name {0} => canonical name {1}", name, objectName, new string(' ', nestingCount * indent)));
}
object instance;
@@ -2123,12 +2122,12 @@ namespace Spring.Objects.Factory.Support
{
if (IsSingletonCurrentlyInCreation(objectName))
{
log.Debug("Returning eagerly cached instance of singleton object '" + objectName +
"' that is not fully initialized yet - a consequence of a circular reference");
log.LogDebug("Returning eagerly cached instance of singleton object '" + objectName +
"' that is not fully initialized yet - a consequence of a circular reference");
}
else
{
log.Debug($"Returning cached instance of singleton object '{objectName}'.");
log.LogDebug($"Returning cached instance of singleton object '{objectName}'.");
}
}
@@ -2227,7 +2226,7 @@ namespace Spring.Objects.Factory.Support
hasErrors = true;
if (log.IsEnabled(LogLevel.Error))
{
log.Error(string.Format("{1}GetObjectInternal: error obtaining object {0}", name, new string(' ', nestingCount * indent)));
log.LogError(string.Format("{1}GetObjectInternal: error obtaining object {0}", name, new string(' ', nestingCount * indent)));
}
throw;
@@ -2246,7 +2245,7 @@ namespace Spring.Objects.Factory.Support
if (isDebugEnabled)
{
log.Debug(string.Format("{1}GetObjectInternal: returning instance for objectname {0}", name, new string(' ', nestingCount * indent)));
log.LogDebug(string.Format("{1}GetObjectInternal: returning instance for objectname {0}", name, new string(' ', nestingCount * indent)));
}
}
}
@@ -2328,7 +2327,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Creating shared instance of singleton object '{0}'", objectName));
log.LogDebug(string.Format("Creating shared instance of singleton object '{0}'", objectName));
}
BeforeSingletonCreation(objectName);
@@ -2344,7 +2343,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Cached shared instance of singleton object '{0}'", objectName));
log.LogDebug(string.Format("Cached shared instance of singleton object '{0}'", objectName));
}
}
return sharedInstance;
@@ -2372,7 +2371,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format("Destroying singletons in factory [{0}].", this));
log.LogDebug(string.Format("Destroying singletons in factory [{0}].", this));
}
prototypesInCreation.Dispose();
@@ -2524,8 +2523,7 @@ namespace Spring.Objects.Factory.Support
{
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.");
log.LogDebug($"Ignoring attempt to Register alias '{alias}' for object with name '{name}' because name and alias would be the same value.");
}
return;
@@ -2533,7 +2531,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"Registering alias '{alias}' for object with name '{name}'.");
log.LogDebug($"Registering alias '{alias}' for object with name '{name}'.");
}
object registeredName = aliasMap[alias];

View File

@@ -93,8 +93,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
$"Object '{objectName}' instantiated via constructor [{constructorInstantiationInfo.ConstructorInfo}].");
log.LogDebug($"Object '{objectName}' instantiated via constructor [{constructorInstantiationInfo.ConstructorInfo}].");
}
return wrapper;
@@ -349,7 +348,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug($"Object '{name}' instantiated via factory method [{factoryMethodCandidate}].");
log.LogDebug($"Object '{name}' instantiated via factory method [{factoryMethodCandidate}].");
}
return wrapper;
@@ -476,8 +475,7 @@ namespace Spring.Objects.Factory.Support
for (var i = 0; i < autowiredObjectNames.Count; i++)
{
string autowiredObjectName = autowiredObjectNames[i];
log.Debug(
$"Autowiring by type from object name '{objectName}' via {GetMethodType()} to object named '{autowiredObjectName}'");
log.LogDebug($"Autowiring by type from object name '{objectName}' via {GetMethodType()} to object named '{autowiredObjectName}'");
}
}

View File

@@ -365,8 +365,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
$"Overriding object definition for object '{name}': replacing [{existingDefinition}] with [{objectDefinition}].");
log.LogDebug($"Overriding object definition for object '{name}': replacing [{existingDefinition}] with [{objectDefinition}].");
}
objectDefinitionMap[name] = objectDefinition;
}
@@ -467,7 +466,7 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Pre-instantiating singletons in factory [" + this + "]");
log.LogDebug("Pre-instantiating singletons in factory [" + this + "]");
}
try
@@ -513,9 +512,7 @@ namespace Spring.Objects.Factory.Support
}
catch (Exception ex)
{
log.Error(
"PreInstantiateSingletons failed but couldn't destroy any already-created singletons.",
ex);
log.LogError(ex, "PreInstantiateSingletons failed but couldn't destroy any already-created singletons.");
}
throw;
}
@@ -995,10 +992,11 @@ namespace Spring.Objects.Factory.Support
// created object itself...
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
string message = string.Format(
CultureInfo.InvariantCulture,
"Ignoring match to currently created object '{0}'.",
objectName), ex);
objectName);
log.LogDebug(ex, message);
}
}
else
@@ -1182,7 +1180,8 @@ namespace Spring.Objects.Factory.Support
// Probably contains a placeholder; lets ignore it for type matching purposes.
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Ignoring object class loading failure for object '" + objectName + "'", ex);
string message = "Ignoring object class loading failure for object '" + objectName + "'";
log.LogDebug(ex, message);
}
}
catch (ObjectDefinitionStoreException ex)
@@ -1195,7 +1194,8 @@ namespace Spring.Objects.Factory.Support
// Probably contains a placeholder; lets ignore it for type matching purposes.
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Ignoring unresolvable metadata in object definition '" + objectName + "'", ex);
string message = "Ignoring unresolvable metadata in object definition '" + objectName + "'";
log.LogDebug(ex, message);
}
}
}

View File

@@ -136,7 +136,7 @@ namespace Spring.Objects.Factory.Support
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Invoking Dispose() on object with name '" + this.objectName + "'");
logger.LogDebug("Invoking Dispose() on object with name '" + this.objectName + "'");
}
try
{
@@ -149,11 +149,11 @@ namespace Spring.Objects.Factory.Support
string msg = "Invocation of Dispose method failed on object with name '" + this.objectName + "'";
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Warn(msg, ex);
logger.LogWarning(ex, msg);
}
else
{
logger.Warn(msg + ": " + ex);
logger.LogWarning(msg + ": " + ex);
}
}
}
@@ -217,8 +217,8 @@ namespace Spring.Objects.Factory.Support
}
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Invoking destroy method '" + this.destroyMethodName +
"' on object with name '" + this.objectName + "'");
logger.LogDebug("Invoking destroy method '" + this.destroyMethodName +
"' on object with name '" + this.objectName + "'");
}
try
{
@@ -231,17 +231,18 @@ namespace Spring.Objects.Factory.Support
"' failed on object with name '" + this.objectName + "'";
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Warn(msg, ex.InnerException);
logger.LogWarning(ex.InnerException, msg);
}
else
{
logger.Warn(msg + ": " + ex.InnerException);
logger.LogWarning(msg + ": " + ex.InnerException);
}
}
catch (Exception ex)
{
logger.Error("Couldn't invoke destroy method '" + this.destroyMethodName +
"' on object with name '" + this.objectName + "'", ex);
string message = "Couldn't invoke destroy method '" + this.destroyMethodName +
"' on object with name '" + this.objectName + "'";
logger.LogError(ex, message);
}
}
}

View File

@@ -189,10 +189,10 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(CultureInfo.InvariantCulture,
"Generating a subclass of the [{0}] class for the '{1}' " +
"object definition for the purposes of method injection.",
definition.ObjectType, objectName));
log.LogDebug(string.Format(CultureInfo.InvariantCulture,
"Generating a subclass of the [{0}] class for the '{1}' " +
"object definition for the purposes of method injection.",
definition.ObjectType, objectName));
}
#endregion

View File

@@ -345,9 +345,8 @@ namespace Spring.Objects.Factory.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.",
argumentName, name, reference.ObjectName));
log.LogDebug(string.Format(CultureInfo.InvariantCulture, "Resolving reference from property '{0}' in object '{1}' to object '{2}'.",
argumentName, name, reference.ObjectName));
}
try

View File

@@ -357,7 +357,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Found object name '" + name + "'");
log.LogDebug("Found object name '" + name + "'");
}
#endregion
@@ -377,7 +377,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Invalid object name and property [" + nameAndProperty + "]");
log.LogDebug("Invalid object name and property [" + nameAndProperty + "]");
}
#endregion
@@ -477,11 +477,11 @@ namespace Spring.Objects.Factory.Support
}
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(pvs.ToString());
log.LogDebug(pvs.ToString());
}
if (parent == null)
{
log.Debug(this.DefaultParentObject);
log.LogDebug(this.DefaultParentObject);
parent = this.DefaultParentObject;
}
if (typeName == null && parent == null)

View File

@@ -73,7 +73,7 @@ namespace Spring.Objects.Factory.Support
AssertUtils.ArgumentNotNull(definition, "definition");
AssertUtils.ArgumentNotNull(factory, "factory");
if (log.IsEnabled(LogLevel.Trace)) log.Trace(string.Format("instantiating object '{0}'", name));
if (log.IsEnabled(LogLevel.Trace)) log.LogTrace(string.Format("instantiating object '{0}'", name));
if (definition.HasMethodOverrides)
{
@@ -201,7 +201,7 @@ namespace Spring.Objects.Factory.Support
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn(msg, ex.InnerException);
log.LogWarning(ex.InnerException, msg);
}
#endregion

View File

@@ -83,7 +83,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Loading object definitions.");
log.LogDebug("Loading object definitions.");
}
XmlElement root = doc.DocumentElement;
@@ -99,8 +99,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
$"Found {readerContext.Registry.ObjectDefinitionCount} <{ObjectDefinitionConstants.ObjectElement}> elements defining objects.");
log.LogDebug($"Found {readerContext.Registry.ObjectDefinitionCount} <{ObjectDefinitionConstants.ObjectElement}> elements defining objects.");
}
}
@@ -190,7 +189,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Registering object definition with id '{0}'.", bdHolder.ObjectName));
log.LogDebug(string.Format(CultureInfo.InvariantCulture, "Registering object definition with id '{0}'.", bdHolder.ObjectName));
}
ObjectDefinitionReaderUtils.RegisterObjectDefinition(bdHolder, ReaderContext.Registry);
@@ -223,9 +222,9 @@ namespace Spring.Objects.Factory.Xml
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
CultureInfo.InvariantCulture,
"Attempting to import object definitions from '{0}'.", location));
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Attempting to import object definitions from '{0}'.", location));
}
IResource importResource = ReaderContext.Resource.CreateRelative(location);

View File

@@ -110,7 +110,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Loading object definitions...");
log.LogDebug("Loading object definitions...");
}
#endregion
@@ -121,10 +121,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default lazy init '{0}'.",
ddd.LazyInit));
log.LogDebug(string.Format(
"Default lazy init '{0}'.",
ddd.LazyInit));
}
#endregion
@@ -135,10 +134,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default dependency check '{0}'.",
ddd.DependencyCheck));
log.LogDebug(string.Format(
"Default dependency check '{0}'.",
ddd.DependencyCheck));
}
#endregion
@@ -149,10 +147,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default autowire '{0}'.",
ddd.Autowire));
log.LogDebug(string.Format(
"Default autowire '{0}'.",
ddd.Autowire));
}
#endregion
@@ -163,10 +160,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default merge '{0}'.",
ddd.Merge));
log.LogDebug(string.Format(
"Default merge '{0}'.",
ddd.Merge));
}
#endregion
@@ -177,10 +173,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default init method '{0}'.",
ddd.InitMethod));
log.LogDebug(string.Format(
"Default init method '{0}'.",
ddd.InitMethod));
}
#endregion
@@ -191,10 +186,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default destroy method '{0}'.",
ddd.DestroyMethod));
log.LogDebug(string.Format(
"Default destroy method '{0}'.",
ddd.DestroyMethod));
}
#endregion
@@ -205,10 +199,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default autowire candidates '{0}'.",
ddd.AutowireCandidates));
log.LogDebug(string.Format(
"Default autowire candidates '{0}'.",
ddd.AutowireCandidates));
}
#endregion
@@ -219,10 +212,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default init method '{0}'.",
ddd.InitMethod));
log.LogDebug(string.Format(
"Default init method '{0}'.",
ddd.InitMethod));
}
#endregion
@@ -233,10 +225,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
"Default destroy method '{0}'.",
ddd.DestroyMethod));
log.LogDebug(string.Format(
"Default destroy method '{0}'.",
ddd.DestroyMethod));
}
#endregion
@@ -341,7 +332,7 @@ namespace Spring.Objects.Factory.Xml
aliases.RemoveAt(0);
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())));
log.LogDebug(string.Format("No XML 'id' specified using '{0}' as object name and '{1}' as aliases", objectName, string.Join(",", aliases.ToArray())));
}
}
}
@@ -382,9 +373,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
"Neither XML '{0}' nor '{1}' specified - using generated object name [{2}]",
ObjectDefinitionConstants.IdAttribute, ObjectDefinitionConstants.NameAttribute, objectName));
log.LogDebug(string.Format(
"Neither XML '{0}' nor '{1}' specified - using generated object name [{2}]",
ObjectDefinitionConstants.IdAttribute, ObjectDefinitionConstants.NameAttribute, objectName));
}
#endregion

View File

@@ -205,7 +205,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Attempting to import object definitions from '{0}'.", location));
}
@@ -313,10 +313,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format(
CultureInfo.InvariantCulture,
"Registering object definition with id '{0}'.", holder.ObjectName));
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Registering object definition with id '{0}'.", holder.ObjectName));
}
#endregion
@@ -838,7 +837,7 @@ namespace Spring.Objects.Factory.Xml
{
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn("The 'type' attribute is redundant when the 'name' attribute has been used on a constructor argument element.");
log.LogWarning("The 'type' attribute is redundant when the 'name' attribute has been used on a constructor argument element.");
}
}
arguments.AddNamedArgumentValue(nameAttr, val);
@@ -1467,9 +1466,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format("Error while parsing dependency checking mode : '{0}' is an invalid value.",
value), ex);
string message = string.Format("Error while parsing dependency checking mode : '{0}' is an invalid value.",
value);
log.LogDebug(ex, message);
}
#endregion
@@ -1509,9 +1508,9 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(
string.Format("Error while parsing autowire mode : '{0}' is an invalid value.",
value), ex);
string message = string.Format("Error while parsing autowire mode : '{0}' is an invalid value.",
value);
log.LogDebug(ex, message);
}
#endregion

View File

@@ -222,7 +222,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Loading XML object definitions from " + resource);
log.LogDebug("Loading XML object definitions from " + resource);
}
#endregion
@@ -252,7 +252,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn("Could not close stream.", ex);
log.LogWarning(ex, "Could not close stream.");
}
#endregion
@@ -340,7 +340,7 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Using the following XmlReader implementation : " + reader.GetType());
log.LogDebug("Using the following XmlReader implementation : " + reader.GetType());
}
return reader;
@@ -375,9 +375,8 @@ namespace Spring.Objects.Factory.Xml
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn(
"Ignored XML validation warning: " + args.Message,
args.Exception);
string message = "Ignored XML validation warning: " + args.Message;
log.LogWarning(args.Exception, message);
}
#endregion

View File

@@ -17,7 +17,7 @@
using System.ComponentModel;
using System.Reflection;
using System.Text;
using Microsoft.Extensions.Logging;
using Spring.Core;
using Spring.Expressions;
using Spring.Expressions.Parser.antlr;
@@ -312,7 +312,8 @@ namespace Spring.Objects
{
if (!ignoreUnknown)
{
Log.Error($"Failed setting property '{pv.Name}'", ex);
string message = $"Failed setting property '{pv.Name}'";
Log.LogError(ex, message);
throw;
}
}
@@ -320,23 +321,27 @@ namespace Spring.Objects
{
if (!ignoreUnknown)
{
Log.Error($"Failed setting property '{pv.Name}'", ex);
string message = $"Failed setting property '{pv.Name}'";
Log.LogError(ex, message);
throw;
}
}
catch (TypeMismatchException ex) // otherwise, just ignore it and continue...
{
Log.Error($"Failed setting property '{pv.Name}'", ex);
string message = $"Failed setting property '{pv.Name}'";
Log.LogError(ex, message);
propertyAccessExceptions.Add(ex);
}
catch (MethodInvocationException ex)
{
Log.Error($"Failed setting property '{pv.Name}'", ex);
string message = $"Failed setting property '{pv.Name}'";
Log.LogError(ex, message);
propertyAccessExceptions.Add(ex);
}
catch (Exception ex)
{
Log.Error($"Failed setting property '{pv.Name}' on instance of type '{WrappedType.FullName}'", ex);
string message = $"Failed setting property '{pv.Name}' on instance of type '{WrappedType.FullName}'";
Log.LogError(ex, message);
throw;
}
}

View File

@@ -207,11 +207,11 @@ namespace Spring.Objects.Support
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug(string.Format(
CultureInfo.InvariantCulture,
"Wiring up this method '{0}' to this event '{1}'",
method.Name,
theEvent.Name));
log.LogDebug(string.Format(
CultureInfo.InvariantCulture,
"Wiring up this method '{0}' to this event '{1}'",
method.Name,
theEvent.Name));
}
#endregion

View File

@@ -121,8 +121,8 @@ namespace Spring.Objects.Support
if (logger.IsEnabled(LogLevel.Warning))
{
logger.Warn("Could not sort objects [" + o1 + "] and [" + o2 + "]",
ex);
string message = "Could not sort objects [" + o1 + "] and [" + o2 + "]";
logger.LogWarning(ex, message);
}
#endregion
@@ -163,7 +163,7 @@ namespace Spring.Objects.Support
// if a nested property cannot be read, simply return null...
if (logger.IsEnabled(LogLevel.Debug))
{
logger.Debug("Could not access property - treating as null for sorting.", ex);
logger.LogDebug(ex, "Could not access property - treating as null for sorting.");
}
}
}

View File

@@ -20,7 +20,7 @@
using System.Diagnostics;
using System.Reflection;
using Microsoft.Extensions.Logging;
namespace Spring.Util
{
@@ -154,7 +154,8 @@ namespace Spring.Util
}
catch(Exception ex)
{
Log.Warn("Error during raising an event from " + new StackTrace(), ex);
string message = "Error during raising an event from " + new StackTrace();
Log.LogWarning(ex, message);
exceptions.Add(sink, ex);
}
}

View File

@@ -206,7 +206,7 @@ namespace Spring.Util
{
AssertUtils.ArgumentNotNull(constructor, "constructor");
if (log.IsEnabled(LogLevel.Trace)) log.Trace(string.Format("instantiating type [{0}] using constructor [{1}]", constructor.DeclaringType, constructor));
if (log.IsEnabled(LogLevel.Trace)) log.LogTrace(string.Format("instantiating type [{0}] using constructor [{1}]", constructor.DeclaringType, constructor));
if (constructor.DeclaringType.IsInterface)
{

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
using Spring.Expressions;
namespace Spring.Validation.Actions
@@ -78,7 +79,8 @@ namespace Spring.Validation.Actions
}
catch (Exception e)
{
log.Error("Was not able to evaluate action expression [" + throwsExpression + "]", e);
string message = "Was not able to evaluate action expression [" + throwsExpression + "]";
log.LogError(e, message);
}
Exception exception = o as Exception;
if (exception != null)

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
using Microsoft.Extensions.Logging;
using NHibernate;
using NHibernate.Engine;
using NHibernate.Proxy;
@@ -66,7 +67,7 @@ namespace Spring.Data.NHibernate.Bytecode
}
catch (Exception ex)
{
log.Error("Creating a proxy instance failed", ex);
log.LogError(ex, "Creating a proxy instance failed");
throw new HibernateException("Creating a proxy instance failed", ex);
}
}

View File

@@ -17,6 +17,7 @@
using System.Collections;
using System.Reflection;
using AopAlliance.Intercept;
using Microsoft.Extensions.Logging;
using NHibernate;
using NHibernate.Impl;
using NHibernate.Type;
@@ -384,7 +385,7 @@ namespace Spring.Data.NHibernate
if (TemplateFlushMode == TemplateFlushMode.Eager ||
(!existingTransaction && TemplateFlushMode != TemplateFlushMode.Never))
{
log.Debug("Eagerly flushing Hibernate session");
log.LogDebug("Eagerly flushing Hibernate session");
session.Flush();
}
}
@@ -467,7 +468,7 @@ namespace Spring.Data.NHibernate
}
else
{
log.Warn("Could not set FetchSize for IQuery. Expected Implemention to be of type AbstractQueryImpl");
log.LogWarning("Could not set FetchSize for IQuery. Expected Implemention to be of type AbstractQueryImpl");
}
}
@@ -577,7 +578,7 @@ namespace Spring.Data.NHibernate
}
catch (TypeLoadException e)
{
log.Warn("Can't set FetchSize for ICriteria", e);
log.LogWarning(e, "Can't set FetchSize for ICriteria");
}
}
@@ -598,7 +599,7 @@ namespace Spring.Data.NHibernate
}
catch (TypeLoadException e)
{
log.Warn("CriteriaImpl not available. FetchSize can not be set on ICriteria objects", e);
log.LogWarning(e, "CriteriaImpl not available. FetchSize can not be set on ICriteria objects");
}
}

View File

@@ -855,7 +855,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Found thread-bound Session for HibernateTemplate");
log.LogDebug("Found thread-bound Session for HibernateTemplate");
}
}
@@ -903,7 +903,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Not closing pre-bound Hibernate Session after HibernateTemplate");
log.LogDebug("Not closing pre-bound Hibernate Session after HibernateTemplate");
}
if (previousFlushModeHolder.ModeWasSet)
{

View File

@@ -282,8 +282,8 @@ namespace Spring.Data.NHibernate
(SessionHolder)TransactionSynchronizationManager.GetResource(SessionFactory);
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Found thread-bound Session [" + sessionHolder.Session +
"] for Hibernate transaction");
log.LogDebug("Found thread-bound Session [" + sessionHolder.Session +
"] for Hibernate transaction");
}
txObject.SetSessionHolder(sessionHolder, false);
if (DbProvider != null)
@@ -359,7 +359,7 @@ namespace Spring.Data.NHibernate
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Opened new Session [" + newSession + "] for Hibernate transaction");
log.LogDebug("Opened new Session [" + newSession + "] for Hibernate transaction");
}
txObject.SetSessionHolder(new SessionHolder(newSession), true);
@@ -414,7 +414,7 @@ namespace Spring.Data.NHibernate
}
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Exposing Hibernate transaction as ADO transaction [" + con + "]");
log.LogDebug("Exposing Hibernate transaction as ADO transaction [" + con + "]");
}
TransactionSynchronizationManager.BindResource(DbProvider, conHolder);
txObject.ConnectionHolder = conHolder;
@@ -527,8 +527,8 @@ namespace Spring.Data.NHibernate
HibernateTransactionObject txObject = (HibernateTransactionObject)status.Transaction;
if (status.Debug)
{
log.Debug("Committing Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "]");
log.LogDebug("Committing Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "]");
}
try
{
@@ -570,8 +570,8 @@ namespace Spring.Data.NHibernate
if (status.Debug)
{
log.Debug("Rolling back Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "]");
log.LogDebug("Rolling back Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "]");
}
try
{
@@ -619,8 +619,8 @@ namespace Spring.Data.NHibernate
HibernateTransactionObject txObject = (HibernateTransactionObject)status.Transaction;
if (status.Debug)
{
log.Debug("Setting Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "] rollback-only");
log.LogDebug("Setting Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "] rollback-only");
}
txObject.SetRollbackOnly();
}
@@ -646,12 +646,12 @@ namespace Spring.Data.NHibernate
}
catch (Exception e)
{
log.Warn("Could not extract IDbTransaction from Hibernate AdoTransaction using field name trans.", e);
log.LogWarning(e, "Could not extract IDbTransaction from Hibernate AdoTransaction using field name trans.");
}
}
else
{
log.Warn("Hibernate ITransaction not of expected type AdoTransaction. Could not extract IDbTransaction from Hibernate AdoTransaction.");
log.LogWarning("Hibernate ITransaction not of expected type AdoTransaction. Could not extract IDbTransaction from Hibernate AdoTransaction.");
}
return adoTransaction;
}
@@ -731,7 +731,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Closing Hibernate Session [" + session + "] after transaction");
log.LogDebug("Closing Hibernate Session [" + session + "] after transaction");
}
SessionFactoryUtils.CloseSessionOrRegisterDeferredClose(session, SessionFactory);
}
@@ -739,7 +739,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Not closing pre-bound Hibernate Session [" + session + "] after transaction");
log.LogDebug("Not closing pre-bound Hibernate Session [" + session + "] after transaction");
}
if (txObject.SessionHolder.AssignedPreviousFlushMode)
{
@@ -938,14 +938,14 @@ namespace Spring.Data.NHibernate
// Use the SessionFactory's DataSource for exposing transactions to ADO.NET code.
if (log.IsEnabled(LogLevel.Information))
{
log.Info("Derived DbProvider [" + sfDbProvider.DbMetadata.ProductName +
"] of Hibernate SessionFactory for HibernateTransactionManager");
log.LogInformation("Derived DbProvider [" + sfDbProvider.DbMetadata.ProductName +
"] of Hibernate SessionFactory for HibernateTransactionManager");
}
DbProvider = sfDbProvider;
}
else
{
log.Info("Could not auto detect DbProvider from SessionFactory configuration");
log.LogInformation("Could not auto detect DbProvider from SessionFactory configuration");
}
}

View File

@@ -287,8 +287,8 @@ namespace Spring.Data.NHibernate
(SessionHolder)TransactionSynchronizationManager.GetResource(SessionFactory);
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Found thread-bound Session [" + sessionHolder.Session +
"] for Hibernate transaction");
log.LogDebug("Found thread-bound Session [" + sessionHolder.Session +
"] for Hibernate transaction");
}
txObject.SetSessionHolder(sessionHolder, false);
if (DbProvider != null)
@@ -380,7 +380,7 @@ namespace Spring.Data.NHibernate
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Opened new Session [" + newSession + "] for Hibernate transaction");
log.LogDebug("Opened new Session [" + newSession + "] for Hibernate transaction");
}
txObject.SetSessionHolder(new SessionHolder(newSession), true);
@@ -435,7 +435,7 @@ namespace Spring.Data.NHibernate
}
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Exposing Hibernate transaction as ADO transaction [" + con + "]");
log.LogDebug("Exposing Hibernate transaction as ADO transaction [" + con + "]");
}
TransactionSynchronizationManager.BindResource(DbProvider, conHolder);
txObject.ConnectionHolder = conHolder;
@@ -617,8 +617,8 @@ namespace Spring.Data.NHibernate
HibernateTransactionObject txObject = (HibernateTransactionObject)status.Transaction;
if (status.Debug)
{
log.Debug("Committing Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "]");
log.LogDebug("Committing Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "]");
}
try
{
@@ -787,8 +787,8 @@ namespace Spring.Data.NHibernate
HibernateTransactionObject txObject = (HibernateTransactionObject)status.Transaction;
if (status.Debug)
{
log.Debug("Setting Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "] rollback-only");
log.LogDebug("Setting Hibernate transaction on Session [" +
txObject.SessionHolder.Session + "] rollback-only");
}
txObject.SetRollbackOnly();
@@ -803,7 +803,7 @@ namespace Spring.Data.NHibernate
{
if (status.Debug)
{
log.Debug("Setting transaction rollback-only");
log.LogDebug("Setting transaction rollback-only");
}
try
{
@@ -836,12 +836,12 @@ namespace Spring.Data.NHibernate
}
catch (Exception e)
{
log.Warn("Could not extract IDbTransaction from Hibernate AdoTransaction using field name trans.", e);
log.LogWarning(e, "Could not extract IDbTransaction from Hibernate AdoTransaction using field name trans.");
}
}
else
{
log.Warn("Hibernate ITransaction not of expected type AdoTransaction. Could not extract IDbTransaction from Hibernate AdoTransaction.");
log.LogWarning("Hibernate ITransaction not of expected type AdoTransaction. Could not extract IDbTransaction from Hibernate AdoTransaction.");
}
return adoTransaction;
}
@@ -933,7 +933,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Closing Hibernate Session [" + session + "] after transaction");
log.LogDebug("Closing Hibernate Session [" + session + "] after transaction");
}
SessionFactoryUtils.CloseSessionOrRegisterDeferredClose(session, SessionFactory);
@@ -942,7 +942,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Not closing pre-bound Hibernate Session [" + session + "] after transaction");
log.LogDebug("Not closing pre-bound Hibernate Session [" + session + "] after transaction");
}
if (txObject.SessionHolder.AssignedPreviousFlushMode)
{
@@ -1101,14 +1101,14 @@ namespace Spring.Data.NHibernate
// Use the SessionFactory's DataSource for exposing transactions to ADO.NET code.
if (log.IsEnabled(LogLevel.Information))
{
log.Info("Derived DbProvider [" + sfDbProvider.DbMetadata.ProductName +
"] of Hibernate SessionFactory for HibernateTransactionManager");
log.LogInformation("Derived DbProvider [" + sfDbProvider.DbMetadata.ProductName +
"] of Hibernate SessionFactory for HibernateTransactionManager");
}
DbProvider = sfDbProvider;
}
else
{
log.Info("Could not auto detect DbProvider from SessionFactory configuration");
log.LogInformation("Could not auto detect DbProvider from SessionFactory configuration");
}
}

View File

@@ -490,8 +490,8 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Information))
{
log.Info("Overriding use of Spring's Hibernate Connection Provider with [" +
hibernateProperties[Environment.ConnectionProvider] + "]");
log.LogInformation("Overriding use of Spring's Hibernate Connection Provider with [" +
hibernateProperties[Environment.ConnectionProvider] + "]");
}
config.Properties.Remove(Environment.ConnectionProvider);
@@ -621,7 +621,7 @@ namespace Spring.Data.NHibernate
}
// Build SessionFactory instance.
log.Info("Building new Hibernate SessionFactory");
log.LogInformation("Building new Hibernate SessionFactory");
configuration = config;
sessionFactory = NewSessionFactory(config);
@@ -640,7 +640,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Information))
{
log.Info("Closing Hibernate SessionFactory");
log.LogInformation("Closing Hibernate SessionFactory");
}
sessionFactory.Close();
@@ -717,7 +717,7 @@ namespace Spring.Data.NHibernate
/// </remarks>
public void DropDatabaseSchema()
{
log.Info("Dropping database schema for NHibernate SessionFactory");
log.LogInformation("Dropping database schema for NHibernate SessionFactory");
HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
hibernateTemplate.Execute(
new HibernateDelegate(session =>
@@ -747,7 +747,7 @@ namespace Spring.Data.NHibernate
/// </remarks>
public void CreateDatabaseSchema()
{
log.Info("Creating database schema for Hibernate SessionFactory");
log.LogInformation("Creating database schema for Hibernate SessionFactory");
HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
hibernateTemplate.Execute(
new HibernateDelegate(session =>
@@ -778,7 +778,7 @@ namespace Spring.Data.NHibernate
/// </remarks>
public virtual void UpdateDatabaseSchema()
{
log.Info("Updating database schema for Hibernate SessionFactory");
log.LogInformation("Updating database schema for Hibernate SessionFactory");
HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
hibernateTemplate.TemplateFlushMode = TemplateFlushMode.Never;
hibernateTemplate.Execute(
@@ -836,7 +836,7 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Executing schema statement: " + sql);
log.LogDebug("Executing schema statement: " + sql);
}
try
{
@@ -847,8 +847,9 @@ namespace Spring.Data.NHibernate
{
if (log.IsEnabled(LogLevel.Warning))
{
log.Warn("Unsuccessful schema statement: " + sql, ex);
}
string message = "Unsuccessful schema statement: " + sql;
log.LogWarning((Exception) ex, message);
}
}
}

View File

@@ -15,6 +15,7 @@
*/
using System.Collections;
using Microsoft.Extensions.Logging;
using NHibernate;
using NHibernate.Connection;
using NHibernate.Driver;
@@ -235,7 +236,7 @@ namespace Spring.Data.NHibernate
session = sessionHolder.ValidatedSession;
if (session != null && !sessionHolder.SynchronizedWithTransaction)
{
log.Debug("Registering Spring transaction synchronization for existing Hibernate Session");
log.LogDebug("Registering Spring transaction synchronization for existing Hibernate Session");
TransactionSynchronizationManager.RegisterSynchronization(
new SpringSessionSynchronization(sessionHolder, sessionFactory, adoExceptionTranslator, false));
sessionHolder.SynchronizedWithTransaction = true;
@@ -270,7 +271,7 @@ namespace Spring.Data.NHibernate
// Thread object will get removed by synchronization at transaction completion.
if (TransactionSynchronizationManager.SynchronizationActive)
{
log.Debug("Registering Spring transaction synchronization for new Hibernate Session");
log.LogDebug("Registering Spring transaction synchronization for new Hibernate Session");
SessionHolder holderToUse = sessionHolder;
if (holderToUse == null)
{
@@ -316,7 +317,7 @@ namespace Spring.Data.NHibernate
/// <returns>the newly opened session</returns>
internal static ISession OpenSession(ISessionFactory sessionFactory, IInterceptor entityInterceptor)
{
log.Debug("Opening Hibernate Session");
log.LogDebug("Opening Hibernate Session");
ISession session = (
(entityInterceptor != null)
? sessionFactory.OpenSession(entityInterceptor)
@@ -335,18 +336,18 @@ namespace Spring.Data.NHibernate
{
if (session != null)
{
log.Debug("Closing Hibernate Session");
log.LogDebug("Closing Hibernate Session");
try
{
session.Close();
}
catch (HibernateException ex)
{
log.Error("Could not close Hibernate Session", ex);
log.LogError(ex, "Could not close Hibernate Session");
}
catch (Exception ex)
{
log.Error("Unexpected exception on closing Hibernate Session", ex);
log.LogError(ex, "Unexpected exception on closing Hibernate Session");
}
}
}
@@ -394,11 +395,14 @@ namespace Spring.Data.NHibernate
"Hibernate operation: " + ex.Message, sqlString, ex.InnerException);
} catch (Exception e)
{
log.Error("Exception thrown during exception translation. Message = [" + e.Message + "]", e);
log.Error("Exception that was attempted to be translated was [" + ex.Message + "]", ex);
string message = "Exception thrown during exception translation. Message = [" + e.Message + "]";
log.LogError(e, message);
string message1 = "Exception that was attempted to be translated was [" + ex.Message + "]";
log.LogError((Exception) ex, message1);
if (ex.InnerException != null)
{
log.Error(" Inner Exception was [" + ex.InnerException.Message + "]", ex.InnerException);
string message2 = " Inner Exception was [" + ex.InnerException.Message + "]";
log.LogError(ex.InnerException, message2);
}
throw new UncategorizedAdoException(e.Message, "", "", e);
}
@@ -501,7 +505,7 @@ namespace Spring.Data.NHibernate
if (holderDictionary != null && sessionFactory != null && holderDictionary.Contains(sessionFactory))
{
log.Debug("Registering Hibernate Session for deferred close");
log.LogDebug("Registering Hibernate Session for deferred close");
// Switch Session to FlushMode.NEVER for remaining lifetime.
session.FlushMode = FlushMode.Never;
Set sessions = (Set) holderDictionary[sessionFactory];
@@ -523,7 +527,7 @@ namespace Spring.Data.NHibernate
{
AssertUtils.ArgumentNotNull(sessionFactory, "No SessionFactory specified");
log.Debug("Initializing deferred close of Hibernate Sessions");
log.LogDebug("Initializing deferred close of Hibernate Sessions");
IDictionary holderDictionary = LogicalThreadContext.GetData(DeferredCloseHolderDataSlotName) as IDictionary;
@@ -569,7 +573,7 @@ namespace Spring.Data.NHibernate
{
throw new InvalidOperationException("Deferred close not active for SessionFactory [" + sessionFactory + "]");
}
log.Debug("Processing deferred close of Hibernate Sessions");
log.LogDebug("Processing deferred close of Hibernate Sessions");
Set sessions = (Set) holderDictionary[sessionFactory];
holderDictionary.Remove(sessionFactory);
foreach (ISession session in sessions)
@@ -687,7 +691,7 @@ namespace Spring.Data.NHibernate
}
else
{
log.Info("Could not derive IDbProvider from SessionFactory");
log.LogInformation("Could not derive IDbProvider from SessionFactory");
}
}
@@ -710,7 +714,7 @@ namespace Spring.Data.NHibernate
{
return new ErrorCodeExceptionTranslator(dbProvider);
}
log.Warn("Using FallbackException Translator. Could not translate from ISessionFactory to IDbProvider");
log.LogWarning("Using FallbackException Translator. Could not translate from ISessionFactory to IDbProvider");
return new FallbackExceptionTranslator();
}

View File

@@ -16,6 +16,7 @@
using System.Collections;
using System.Data;
using Microsoft.Extensions.Logging;
using NHibernate;
using Spring.Transaction.Support;
@@ -295,7 +296,7 @@ namespace Spring.Data.NHibernate
{
if (sessionDictionary.ContainsKey(key))
{
log.Debug("Overwriting Session in SessionHolder with key = "+ key);
log.LogDebug("Overwriting Session in SessionHolder with key = "+ key);
}
sessionDictionary[key] = session;

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
using Microsoft.Extensions.Logging;
using NHibernate;
using NHibernate.Engine;
using Spring.Core;
@@ -133,7 +134,7 @@ namespace Spring.Data.NHibernate
if (!readOnly)
{
// read-write transaction -> flush the Hibernate Session
log.Debug("Flushing Hibernate Session on transaction synchronization");
log.LogDebug("Flushing Hibernate Session on transaction synchronization");
ISession session = this.sessionHolder.Session;
//Further check: only flush when not FlushMode.NEVER
if (session.FlushMode != FlushMode.Never)

View File

@@ -320,12 +320,12 @@ namespace Spring.Data.NHibernate.Support
if (TransactionSynchronizationManager.HasResource(SessionFactory))
{
// Do not modify the Session: just set the participate flag.
if (isDebugEnabled) log.Debug("Participating in existing Hibernate SessionFactory");
if (isDebugEnabled) log.LogDebug("Participating in existing Hibernate SessionFactory");
SetParticipating(true);
}
else
{
if (isDebugEnabled) log.Debug("Opening single Hibernate Session in SessionScope");
if (isDebugEnabled) log.LogDebug("Opening single Hibernate Session in SessionScope");
TransactionSynchronizationManager.BindResource(SessionFactory, new LazySessionHolder(this));
}
}
@@ -335,12 +335,12 @@ namespace Spring.Data.NHibernate.Support
if (SessionFactoryUtils.IsDeferredCloseActive(SessionFactory))
{
// Do not modify deferred close: just set the participate flag.
if (isDebugEnabled) log.Debug("Participating in active deferred close mode");
if (isDebugEnabled) log.LogDebug("Participating in active deferred close mode");
SetParticipating(true);
}
else
{
if (isDebugEnabled) log.Debug("Initializing deferred close mode");
if (isDebugEnabled) log.LogDebug("Initializing deferred close mode");
SessionFactoryUtils.InitDeferredClose(SessionFactory);
}
}
@@ -355,7 +355,7 @@ namespace Spring.Data.NHibernate.Support
public void Close()
{
bool isDebugEnabled = log.IsEnabled(LogLevel.Debug);
if (isDebugEnabled) log.Debug("Trying to close SessionScope");
if (isDebugEnabled) log.LogDebug("Trying to close SessionScope");
if (IsOpen)
{
@@ -371,7 +371,7 @@ namespace Spring.Data.NHibernate.Support
}
else
{
if (isDebugEnabled) log.Debug("SessionScope is already closed - doing nothing");
if (isDebugEnabled) log.LogDebug("SessionScope is already closed - doing nothing");
}
}
@@ -382,20 +382,20 @@ namespace Spring.Data.NHibernate.Support
if (SingleSession)
{
// single session mode
if (isLogDebugEnabled) log.Debug("Closing single Hibernate Session in SessionScope");
if (isLogDebugEnabled) log.LogDebug("Closing single Hibernate Session in SessionScope");
LazySessionHolder holder = (LazySessionHolder)TransactionSynchronizationManager.UnbindResource(SessionFactory);
holder.Close();
}
else
{
// deferred close mode
if (isLogDebugEnabled) log.Debug("Closing all Hibernate Sessions");
if (isLogDebugEnabled) log.LogDebug("Closing all Hibernate Sessions");
SessionFactoryUtils.ProcessDeferredClose(SessionFactory);
}
}
else
{
if (isLogDebugEnabled) log.Debug("Only participated Hibernate Session - doing nothing");
if (isLogDebugEnabled) log.LogDebug("Only participated Hibernate Session - doing nothing");
}
}
@@ -424,7 +424,7 @@ namespace Spring.Data.NHibernate.Support
/// </summary>
public LazySessionHolder(SessionScope owner)
{
if (log.IsEnabled(LogLevel.Debug)) log.Debug("Created LazySessionHolder");
if (log.IsEnabled(LogLevel.Debug)) log.LogDebug("Created LazySessionHolder");
this.owner = owner;
}
@@ -435,7 +435,7 @@ namespace Spring.Data.NHibernate.Support
{
if (session == null)
{
if (log.IsEnabled(LogLevel.Debug)) log.Debug("session instance requested - opening new session");
if (log.IsEnabled(LogLevel.Debug)) log.LogDebug("session instance requested - opening new session");
session = owner.DoOpenSession();
AddSession(session);
}
@@ -453,7 +453,7 @@ namespace Spring.Data.NHibernate.Support
session = null;
SessionFactoryUtils.CloseSession(tmpSession);
}
if (log.IsEnabled(LogLevel.Debug)) log.Debug("Closed LazySessionHolder");
if (log.IsEnabled(LogLevel.Debug)) log.LogDebug("Closed LazySessionHolder");
}
}
}

View File

@@ -114,7 +114,7 @@ namespace Spring.Data.Common
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Loading additional DbProviders from " + DBPROVIDER_ADDITIONAL_RESOURCE_NAME);
log.LogDebug("Loading additional DbProviders from " + DBPROVIDER_ADDITIONAL_RESOURCE_NAME);
}
ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME,
@@ -128,13 +128,13 @@ namespace Spring.Data.Common
if (log.IsEnabled(LogLevel.Information))
{
var dbProviderNames = ctx.GetObjectNames<IDbProvider>();
log.Info(
$"{dbProviderNames.Count} DbProviders Available. [{StringUtils.CollectionToCommaDelimitedString(dbProviderNames)}]");
log.LogInformation($"{dbProviderNames.Count} DbProviders Available. [{StringUtils.CollectionToCommaDelimitedString(dbProviderNames)}]");
}
}
catch (Exception e)
{
log.Error("Error processing " + DBPROVIDER_DEFAULT_RESOURCE_NAME, e);
string message = "Error processing " + DBPROVIDER_DEFAULT_RESOURCE_NAME;
log.LogError(e, message);
throw;
}
}

View File

@@ -278,7 +278,7 @@ namespace Spring.Data.Common
{
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("No DbProvider defined in thread local storage, falling back to use DefaultDbProvider.");
LOG.LogDebug("No DbProvider defined in thread local storage, falling back to use DefaultDbProvider.");
}
return defaultDbProvider;
}

View File

@@ -144,7 +144,7 @@ namespace Spring.Data.Core
IDbConnection newCon = DbProvider.CreateConnection();
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Acquired Connection [" + newCon + ", " + newCon.ConnectionString + "] for ADO.NET transaction");
log.LogDebug("Acquired Connection [" + newCon + ", " + newCon.ConnectionString + "] for ADO.NET transaction");
}
newCon.Open();
@@ -261,7 +261,7 @@ namespace Spring.Data.Core
if (status.Debug)
{
IDbConnection conn = txMgrStateObject.ConnectionHolder.Connection;
log.Debug("Committing ADO.NET transaction on Connection [" + conn + ", " + conn.ConnectionString + "]");
log.LogDebug("Committing ADO.NET transaction on Connection [" + conn + ", " + conn.ConnectionString + "]");
}
try
{
@@ -292,7 +292,7 @@ namespace Spring.Data.Core
IDbTransaction trans = txMgrStateObject.ConnectionHolder.Transaction;
if (status.Debug)
{
log.Debug("Rolling back ADO.NET transaction on Connection [" + conn + ", " + conn.ConnectionString + "]" );
log.LogDebug("Rolling back ADO.NET transaction on Connection [" + conn + ", " + conn.ConnectionString + "]");
}
try
{
@@ -319,7 +319,7 @@ namespace Spring.Data.Core
if (status.Debug)
{
IDbConnection conn = txMgrStateObject.ConnectionHolder.Connection;
log.Debug("Setting ADO.NET transaction [" + conn + ", " + conn.ConnectionString + "] rollback-only.");
log.LogDebug("Setting ADO.NET transaction [" + conn + ", " + conn.ConnectionString + "] rollback-only.");
}
txMgrStateObject.SetRollbackOnly();
@@ -337,7 +337,7 @@ namespace Spring.Data.Core
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Releasing ADO.NET Connection [" + con + ", " + con.ConnectionString + "] after transaction");
log.LogDebug("Releasing ADO.NET Connection [" + con + ", " + con.ConnectionString + "] after transaction");
}
ConnectionUtils.DisposeConnection(con, DbProvider);

View File

@@ -168,7 +168,7 @@ namespace Spring.Data.Core
}
else
{
LOG.Warn("Ignoring assignment of DataReaderWrapperType since it has already been assigned.");
LOG.LogWarning("Ignoring assignment of DataReaderWrapperType since it has already been assigned.");
}
}
@@ -368,7 +368,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing NonQuery " + cmdType + "[" + cmdText + "]");
LOG.LogDebug("Executing NonQuery " + cmdType + "[" + cmdText + "]");
}
#endregion
@@ -407,7 +407,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing NonQuery. " + cmdType + "[" + cmdText + "]");
LOG.LogDebug("Executing NonQuery. " + cmdType + "[" + cmdText + "]");
}
#endregion
@@ -429,7 +429,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing NonQuery. " + cmdType + "[" + cmdText + "]");
LOG.LogDebug("Executing NonQuery. " + cmdType + "[" + cmdText + "]");
}
#endregion
@@ -522,7 +522,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing ExecuteScalar. " + cmdType + "[" + cmdText + "]");
LOG.LogDebug("Executing ExecuteScalar. " + cmdType + "[" + cmdText + "]");
}
#endregion
@@ -722,7 +722,7 @@ namespace Spring.Data.Core
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing SQL [" + sql + "]");
LOG.LogDebug("Executing SQL [" + sql + "]");
}
return Execute(new QueryCallback(this, cmdType, sql, rse, null));
@@ -773,7 +773,7 @@ namespace Spring.Data.Core
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing SQL [" + sql + "]");
LOG.LogDebug("Executing SQL [" + sql + "]");
}
return Execute(new QueryCallback(this, cmdType, sql, resultSetExtractorDelegate, null));
@@ -1139,7 +1139,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing DataTableFill " + commandType + "[" + sql + "]");
LOG.LogDebug("Executing DataTableFill " + commandType + "[" + sql + "]");
}
#endregion
@@ -1157,7 +1157,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing DataTableFill " + commandType + "[" + sql + "] with table mapping name " + tableMappingName);
LOG.LogDebug("Executing DataTableFill " + commandType + "[" + sql + "] with table mapping name " + tableMappingName);
}
#endregion
@@ -1478,7 +1478,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing DataSetFill " + commandType + "[" + sql + "]");
LOG.LogDebug("Executing DataSetFill " + commandType + "[" + sql + "]");
}
#endregion
@@ -1498,7 +1498,7 @@ namespace Spring.Data.Core
#region Instrumentation
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing DataSetFill " + commandType + "[" + sql + "] with table names " + tableNames);
LOG.LogDebug("Executing DataSetFill " + commandType + "[" + sql + "] with table names " + tableNames);
}
#endregion
@@ -2538,21 +2538,23 @@ namespace Spring.Data.Core
//Will only have possibility of run-time type error if using QueryWithCommandCreator
if (namedResultSetProcessor == null)
{
LOG.Error("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor. Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
LOG.LogError("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor. Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
continue;
}
}
catch (IndexOutOfRangeException e)
{
LOG.Error("No NamedResultSetProcessor associated with result set index " + resultSetIndex, e);
string message = "No NamedResultSetProcessor associated with result set index " + resultSetIndex;
LOG.LogError(e, message);
continue;
}
catch (ArgumentOutOfRangeException e)
{
LOG.Error("No NamedResultSetProcessor associated with result set index " + resultSetIndex, e);
string message = "No NamedResultSetProcessor associated with result set index " + resultSetIndex;
LOG.LogError(e, message);
continue;
}
@@ -2793,7 +2795,7 @@ namespace Spring.Data.Core
Object rowsAffected = command.ExecuteNonQuery();
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("ExecuteNonQuery affected " + rowsAffected + " rows");
LOG.LogDebug("ExecuteNonQuery affected " + rowsAffected + " rows");
}
return rowsAffected;
}
@@ -2859,7 +2861,7 @@ namespace Spring.Data.Core
Object returnValue = command.ExecuteScalar();
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("ExecuteScalar return value = " + returnValue);
LOG.LogDebug("ExecuteScalar return value = " + returnValue);
}
return returnValue;
}

View File

@@ -150,8 +150,8 @@ namespace Spring.Data.Core
serviceDomainTxObject.ServiceDomainAdapter.Enter(serviceConfig);
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Context created. TransactionId = " + ContextUtil.TransactionId
+ ", ActivityId = " + ContextUtil.ActivityId);
log.LogDebug("Context created. TransactionId = " + ContextUtil.TransactionId
+ ", ActivityId = " + ContextUtil.ActivityId);
}
}
@@ -199,7 +199,7 @@ namespace Spring.Data.Core
case System.Data.IsolationLevel.Chaos:
if (log.IsEnabled(LogLevel.Information))
{
log.Info("IsolationLevel Chaos does not have a direct counterpart in EnterpriseServices, using Any");
log.LogInformation("IsolationLevel Chaos does not have a direct counterpart in EnterpriseServices, using Any");
}
serviceConfig.IsolationLevel = TransactionIsolationLevel.Any;
break;
@@ -218,7 +218,7 @@ namespace Spring.Data.Core
case System.Data.IsolationLevel.Snapshot:
if (log.IsEnabled(LogLevel.Information))
{
log.Info("IsolationLevel Snapshot does not have a direct counterpart in EnterpriseServices, using ReadCommitted. Introduced in SqlServer 2005. Consider using System.Transactions for transaction management instead.");
log.LogInformation("IsolationLevel Snapshot does not have a direct counterpart in EnterpriseServices, using ReadCommitted. Introduced in SqlServer 2005. Consider using System.Transactions for transaction management instead.");
}
serviceConfig.IsolationLevel = TransactionIsolationLevel.ReadCommitted; //err on the side of consistency
break;
@@ -254,9 +254,9 @@ namespace Spring.Data.Core
} else
{
//TODO Should we throw an exception instead?
log.Warn("The requested transaction propagation option " +
definition.PropagationBehavior + " is not supported. " +
"Defaulting to Never(Disabled) ");
log.LogWarning("The requested transaction propagation option " +
definition.PropagationBehavior + " is not supported. " +
"Defaulting to Never(Disabled) ");
}
}
@@ -284,7 +284,7 @@ namespace Spring.Data.Core
TransactionStatus serviceDomainTxstatus = txObject.ServiceDomainAdapter.Leave();
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("ServiceDomain Transaction Status upon leaving ServiceDomain = " + serviceDomainTxstatus);
log.LogDebug("ServiceDomain Transaction Status upon leaving ServiceDomain = " + serviceDomainTxstatus);
}
txObject.TransactionStatus = serviceDomainTxstatus;
if (!globalRollbackOnly && serviceDomainTxstatus == TransactionStatus.Aborted)
@@ -329,7 +329,7 @@ namespace Spring.Data.Core
ServiceDomainTransactionObject txObject = (ServiceDomainTransactionObject)status.Transaction;
if (status.Debug)
{
log.Debug("Setting transaction rollback-only");
log.LogDebug("Setting transaction rollback-only");
}
try
{

View File

@@ -15,6 +15,7 @@
*/
using System.Transactions;
using Microsoft.Extensions.Logging;
using Spring.Data.Support;
using Spring.Objects.Factory;
using Spring.Transaction;
@@ -146,7 +147,7 @@ namespace Spring.Data.Core
{
if (status.Debug)
{
log.Debug("Setting transaction rollback-only");
log.LogDebug("Setting transaction rollback-only");
}
try

View File

@@ -873,7 +873,7 @@ namespace Spring.Data.Generic
AssertUtils.ArgumentNotNull(cmdText, "cmdText", "CommandText must not be null");
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing CommandText [" + cmdText + "]");
LOG.LogDebug("Executing CommandText [" + cmdText + "]");
}
return Execute<T>(new QueryCallback<T>(this, cmdType, cmdText, resultSetExtractor, null));
}
@@ -927,7 +927,7 @@ namespace Spring.Data.Generic
AssertUtils.ArgumentNotNull(resultSetExtractorDelegate, "resultSetExtractorDelegate", "Result set extractor delegate must not be null");
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Executing CommandText [" + cmdText + "]");
LOG.LogDebug("Executing CommandText [" + cmdText + "]");
}
return Execute<T>(new QueryCallback<T>(this, cmdType, cmdText, resultSetExtractorDelegate, null));
@@ -1501,10 +1501,10 @@ namespace Spring.Data.Generic
//Will have possibility of run-time type error if using QueryWithCommandCreator
if (firstResultSetProcessor == null)
{
LOG.Error("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor<T>. Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
LOG.LogError("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor<T>. Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
continue;
}
}
@@ -1515,22 +1515,24 @@ namespace Spring.Data.Generic
if (otherResultSetProcessor == null)
{
LOG.Error("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
LOG.LogError("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
continue;
}
}
}
catch (IndexOutOfRangeException e)
{
LOG.Error("No NamedResultSetProcessor associated with result set index " + resultSetIndex, e);
string message = "No NamedResultSetProcessor associated with result set index " + resultSetIndex;
LOG.LogError(e, message);
continue;
}
catch (ArgumentOutOfRangeException e)
{
LOG.Error("No NamedResultSetProcessor associated with result set index " + resultSetIndex, e);
string message = "No NamedResultSetProcessor associated with result set index " + resultSetIndex;
LOG.LogError(e, message);
continue;
}
@@ -1601,10 +1603,10 @@ namespace Spring.Data.Generic
if (firstResultSetProcessor == null)
{
LOG.Error("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor<T> Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
LOG.LogError("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor<T> Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
continue;
}
} else if (resultSetIndex == 1)
@@ -1614,10 +1616,10 @@ namespace Spring.Data.Generic
if (secondResultSetProcessor == null)
{
LOG.Error("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor<T> Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
LOG.LogError("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor<T> Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
continue;
}
} else
@@ -1627,10 +1629,10 @@ namespace Spring.Data.Generic
if (otherResultSetProcessor == null)
{
LOG.Error("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
LOG.LogError("NamedResultSetProcessor for result set index " + resultSetIndex +
", is not of expected type NamedResultSetProcessor Type = " +
namedResultSetProcessors[resultSetIndex].GetType() +
"; Skipping processing for this result set.");
continue;
}
}
@@ -1638,12 +1640,14 @@ namespace Spring.Data.Generic
}
catch (IndexOutOfRangeException e)
{
LOG.Error("No NamedResultSetProcessor associated with result set index " + resultSetIndex, e);
string message = "No NamedResultSetProcessor associated with result set index " + resultSetIndex;
LOG.LogError(e, message);
continue;
}
catch (ArgumentOutOfRangeException e)
{
LOG.Error("No NamedResultSetProcessor associated with result set index " + resultSetIndex, e);
string message = "No NamedResultSetProcessor associated with result set index " + resultSetIndex;
LOG.LogError(e, message);
continue;
}

View File

@@ -20,6 +20,7 @@
using System.Collections;
using System.Data;
using Microsoft.Extensions.Logging;
using Spring.Dao;
using Spring.Data.Common;
using Spring.Objects.Factory;
@@ -178,7 +179,7 @@ namespace Spring.Data.Objects
{
if (!Compiled)
{
log.Debug("ADO operation not compiled before execution - invoking compile");
log.LogDebug("ADO operation not compiled before execution - invoking compile");
Compile();
}
}

View File

@@ -1,4 +1,5 @@
using System.Data;
using Microsoft.Extensions.Logging;
namespace Spring.Data.Support
{
@@ -65,7 +66,7 @@ namespace Spring.Data.Support
}
catch (Exception e)
{
LOG.Warn("Could not close IDataRader", e);
LOG.LogWarning(e, "Could not close IDataRader");
}
}
}
@@ -78,7 +79,7 @@ namespace Spring.Data.Support
}
catch (Exception e)
{
LOG.Warn("Could not dispose of command", e);
LOG.LogWarning(e, "Could not dispose of command");
}
}

View File

@@ -53,7 +53,7 @@ namespace Spring.Data.Support
}
catch (Exception e)
{
LOG.Warn("Could not close connection", e);
LOG.LogWarning(e, "Could not close connection");
}
}
@@ -76,7 +76,7 @@ namespace Spring.Data.Support
}
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Disposing of IDbConnection with connection string = [" + dbProvider.ConnectionString + "]");
LOG.LogDebug("Disposing of IDbConnection with connection string = [" + dbProvider.ConnectionString + "]");
}
conn.Dispose();
}
@@ -132,7 +132,7 @@ namespace Spring.Data.Support
{
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Fetching resumed ADO.NET connection from DbProvider");
LOG.LogDebug("Fetching resumed ADO.NET connection from DbProvider");
}
conHolder.Connection = provider.CreateConnection();
}
@@ -142,14 +142,14 @@ namespace Spring.Data.Support
// Else we either got no holder or an empty thread-bound holder here.
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Fetching Connection from DbProvider");
LOG.LogDebug("Fetching Connection from DbProvider");
}
IDbConnection conn = provider.CreateConnection();
conn.Open();
if (TransactionSynchronizationManager.SynchronizationActive)
{
LOG.Debug("Registering transaction synchronization for IDbConnection");
LOG.LogDebug("Registering transaction synchronization for IDbConnection");
//Use same connection for further ADO.NET actions with the transaction.
//Thread-bound object will get removed by manager at transaction completion.

View File

@@ -169,7 +169,7 @@ namespace Spring.Data.Support
// Looking for a fallback...
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Unable to translate exception with errorCode '" + errorCode + "', will use the fallback translator");
log.LogDebug("Unable to translate exception with errorCode '" + errorCode + "', will use the fallback translator");
}
IAdoExceptionTranslator fallback = FallbackTranslator;
if (fallback != null)
@@ -327,9 +327,9 @@ namespace Spring.Data.Support
if (log.IsEnabled(LogLevel.Debug))
{
String intro = "Translating";
log.Debug(intro + " ADO exception with error code '" + errorCode
+ "', message [" + exception.Message +
"]; SQL was [" + sql + "] for task [" + task + "]");
log.LogDebug(intro + " ADO exception with error code '" + errorCode
+ "', message [" + exception.Message +
"]; SQL was [" + sql + "] for task [" + task + "]");
}
}

View File

@@ -20,6 +20,7 @@
using System.Data;
using System.Reflection;
using Microsoft.Extensions.Logging;
using Spring.Data.Common;
namespace Spring.Data.Support
@@ -130,7 +131,7 @@ namespace Spring.Data.Support
}
else
{
LOG.Warn("Could not extract IDbDataAdapter from TypedDataset.");
LOG.LogWarning("Could not extract IDbDataAdapter from TypedDataset.");
}
@@ -146,7 +147,7 @@ namespace Spring.Data.Support
}
else
{
LOG.Warn("Could not extract IDbCommand collection from TypedDataset.");
LOG.LogWarning("Could not extract IDbCommand collection from TypedDataset.");
}
}

View File

@@ -174,8 +174,8 @@ namespace Spring.Transaction.Interceptor
// method name specification now -> (re-)register method.
if (LOG.IsEnabled(LogLevel.Debug) && regularMethodName != null)
{
LOG.Debug("Replacing attribute for transactional method [" + currentMethod + "]: current name '" +
name + "' is more specific than '" + regularMethodName + "'");
LOG.LogDebug("Replacing attribute for transactional method [" + currentMethod + "]: current name '" +
name + "' is more specific than '" + regularMethodName + "'");
}
_nameMap.Add( currentMethod, name );
AddTransactionalMethod( currentMethod, transactionAttribute );
@@ -184,8 +184,8 @@ namespace Spring.Transaction.Interceptor
{
if (LOG.IsEnabled(LogLevel.Debug) && regularMethodName != null)
{
LOG.Debug("Keeping attribute for transactional method [" + currentMethod + "]: current name '" +
name + "' is not more specific than '" + regularMethodName + "'");
LOG.LogDebug("Keeping attribute for transactional method [" + currentMethod + "]: current name '" +
name + "' is not more specific than '" + regularMethodName + "'");
}
}
}

View File

@@ -160,7 +160,7 @@ namespace Spring.Transaction.Interceptor
#region Instrumentation
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Adding transactional method [" + methodName + "] with attribute [" + attribute + "]");
log.LogDebug("Adding transactional method [" + methodName + "] with attribute [" + attribute + "]");
}
#endregion
nameMap.Add( methodName, attribute );

View File

@@ -350,7 +350,7 @@ namespace Spring.Transaction.Interceptor
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Getting transaction for " + transactionInfo.JoinpointIdentification);
log.LogDebug("Getting transaction for " + transactionInfo.JoinpointIdentification);
}
#endregion
@@ -364,8 +364,8 @@ namespace Spring.Transaction.Interceptor
// the ThreadLocal stack maintained in this class.
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Skipping transactional joinpoint [" + joinpointIdentification +
"] because no transaction manager has been configured");
log.LogDebug("Skipping transactional joinpoint [" + joinpointIdentification +
"] because no transaction manager has been configured");
}
}
@@ -407,7 +407,7 @@ namespace Spring.Transaction.Interceptor
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Completing transaction for [" + transactionInfo.JoinpointIdentification + "]");
log.LogDebug("Completing transaction for [" + transactionInfo.JoinpointIdentification + "]");
}
#endregion
@@ -437,7 +437,7 @@ namespace Spring.Transaction.Interceptor
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Completing transaction for [" + transactionInfo.JoinpointIdentification + "] after exception: " + exception);
log.LogDebug("Completing transaction for [" + transactionInfo.JoinpointIdentification + "] after exception: " + exception);
}
if ( transactionInfo.TransactionAttribute.RollbackOn( exception ))
@@ -448,7 +448,7 @@ namespace Spring.Transaction.Interceptor
}
catch (Exception e)
{
log.Error("Application exception overridden by rollback exception", e);
log.LogError(e, "Application exception overridden by rollback exception");
throw;
}
}
@@ -461,7 +461,7 @@ namespace Spring.Transaction.Interceptor
_transactionManager.Commit(transactionInfo.TransactionStatus);
} catch (Exception e)
{
log.Error("Application exception overriden by commit exception", e);
log.LogError(e, "Application exception overriden by commit exception");
throw;
}

View File

@@ -443,8 +443,8 @@ namespace Spring.Transaction.Support
protected virtual void RegisterAfterCompletionWithExistingTransaction(Object transaction, IList synchronizations)
{
log.Debug("Cannot register Spring after-completion synchronization with existing transaction - " +
"processing Spring after-completion callbacks immediately, with outcome status 'unknown'");
log.LogDebug("Cannot register Spring after-completion synchronization with existing transaction - " +
"processing Spring after-completion callbacks immediately, with outcome status 'unknown'");
InvokeAfterCompletion(synchronizations, TransactionSynchronizationStatus.Unknown);
}
@@ -516,7 +516,7 @@ namespace Spring.Transaction.Support
if (debugEnabled)
{
log.Debug("Using transaction object [" + transaction + "]");
log.LogDebug("Using transaction object [" + transaction + "]");
}
if (definition == null)
@@ -548,7 +548,7 @@ namespace Spring.Transaction.Support
object suspendedResources = Suspend(null);
if (debugEnabled)
{
log.Debug("Creating new transaction with name [" + definition.Name + "]:" + definition);
log.LogDebug("Creating new transaction with name [" + definition.Name + "]:" + definition);
}
try
{
@@ -610,7 +610,7 @@ namespace Spring.Transaction.Support
{
if (debugEnabled)
{
log.Debug("Suspending current transaction");
log.LogDebug("Suspending current transaction");
}
object suspendedResources = Suspend(transaction);
bool newSynchronization = (_transactionSyncState == TransactionSynchronizationState.Always);
@@ -623,8 +623,8 @@ namespace Spring.Transaction.Support
{
if (debugEnabled)
{
log.Debug("Suspending current transaction, creating new transaction with name [" +
definition.Name + "]:" + definition);
log.LogDebug("Suspending current transaction, creating new transaction with name [" +
definition.Name + "]:" + definition);
}
object suspendedResources = Suspend(transaction);
try
@@ -646,10 +646,9 @@ namespace Spring.Transaction.Support
}
catch (TransactionException resumeEx)
{
log.Error(
"Inner transaction begin exception overridden by outer transaction resume exception");
log.Error("Begin Transaction Exception", beginEx);
log.Error("Resume Transaction Exception", resumeEx);
log.LogError("Inner transaction begin exception overridden by outer transaction resume exception");
log.LogError(beginEx, "Begin Transaction Exception");
log.LogError(resumeEx, "Resume Transaction Exception");
throw;
}
throw;
@@ -665,7 +664,7 @@ namespace Spring.Transaction.Support
}
if (debugEnabled)
{
log.Debug("Creating nested transaction with name [" + definition.Name + "]:" + definition);
log.LogDebug("Creating nested transaction with name [" + definition.Name + "]:" + definition);
}
if (UseSavepointForNestedTransaction())
@@ -688,7 +687,7 @@ namespace Spring.Transaction.Support
// Assumably PROPAGATION_SUPPORTS.
if (debugEnabled)
{
log.Debug("Participating in existing transaction");
log.LogDebug("Participating in existing transaction");
}
//TODO: this block related to un-ported java feature permitting setting the ValidateExistingTransaction flag
@@ -749,7 +748,7 @@ namespace Spring.Transaction.Support
{
if (defaultStatus.Debug)
{
log.Debug("Transaction code has requested rollback");
log.LogDebug("Transaction code has requested rollback");
}
ProcessRollback(defaultStatus);
return;
@@ -758,7 +757,7 @@ namespace Spring.Transaction.Support
{
if (defaultStatus.Debug)
{
log.Debug("Global transaction is marked as rollback-only but transactional code requested commit");
log.LogDebug("Global transaction is marked as rollback-only but transactional code requested commit");
}
ProcessRollback(defaultStatus);
// Throw UnexpectedRollbackException only at outermost transaction boundary
@@ -859,7 +858,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Trigger AfterCommit Synchronization");
log.LogDebug("Trigger AfterCommit Synchronization");
}
IList synchronizations = TransactionSynchronizationManager.Synchronizations;
foreach (ITransactionSynchronization currentTxnSynchronization in synchronizations)
@@ -870,7 +869,7 @@ namespace Spring.Transaction.Support
}
catch (Exception e)
{
log.Error("TransactionSynchronization.AfterCommit thew exception", e);
log.LogError(e, "TransactionSynchronization.AfterCommit thew exception");
}
}
}
@@ -923,7 +922,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Rolling back transaction to savepoint.");
log.LogDebug("Rolling back transaction to savepoint.");
}
status.RollbackToHeldSavepoint();
}
@@ -931,7 +930,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Initiating transaction rollback");
log.LogDebug("Initiating transaction rollback");
}
DoRollback(status);
}
@@ -941,14 +940,14 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Participating transaction failed - marking existing transaction as rollback-only");
log.LogDebug("Participating transaction failed - marking existing transaction as rollback-only");
}
}
DoSetRollbackOnly(status);
}
else
{
log.Debug("Should roll back transaction but cannot - no transaction available.");
log.LogDebug("Should roll back transaction but cannot - no transaction available.");
}
}
catch (Exception)
@@ -1135,7 +1134,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Initiating transaction rollback on commit exception.");
log.LogDebug("Initiating transaction rollback on commit exception.");
}
DoRollback(status);
}
@@ -1143,7 +1142,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Marking existing transaction as rollback-only after commit exception", exception);
log.LogDebug(exception, "Marking existing transaction as rollback-only after commit exception");
}
DoSetRollbackOnly(status);
}
@@ -1151,7 +1150,7 @@ namespace Spring.Transaction.Support
catch (Exception)
{
//TODO investigate rollback behavior...
log.Error("Commit exception overridden by rollback exception", exception);
log.LogError(exception, "Commit exception overridden by rollback exception");
TriggerAfterCompletion(status, TransactionSynchronizationStatus.Unknown);
throw;
}
@@ -1184,7 +1183,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Trigger BeforeCompletion Synchronization");
log.LogDebug("Trigger BeforeCompletion Synchronization");
}
IList synchronizations = TransactionSynchronizationManager.Synchronizations;
foreach (ITransactionSynchronization synchronization in synchronizations)
@@ -1195,7 +1194,7 @@ namespace Spring.Transaction.Support
}
catch (Exception e)
{
log.Error("TransactionSynchronization.BeforeCompletion threw exception", e);
log.LogError(e, "TransactionSynchronization.BeforeCompletion threw exception");
}
}
}
@@ -1217,14 +1216,14 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Triggering afterCompletion synchronization");
log.LogDebug("Triggering afterCompletion synchronization");
}
InvokeAfterCompletion(synchronizations, completionStatus);
}
else
{
//TODO investigate parallel of JTA/System.Txs
log.Info("Transaction controlled outside of spring tx manager.");
log.LogInformation("Transaction controlled outside of spring tx manager.");
RegisterAfterCompletionWithExistingTransaction(status.Transaction, synchronizations);
}
}
@@ -1240,7 +1239,7 @@ namespace Spring.Transaction.Support
}
catch (Exception e)
{
log.Error("TransactionSynchronization.AfterCompletion threw exception", e);
log.LogError(e, "TransactionSynchronization.AfterCompletion threw exception");
}
}
}
@@ -1265,7 +1264,7 @@ namespace Spring.Transaction.Support
{
if (status.Debug)
{
log.Debug("Resuming suspended transaction");
log.LogDebug("Resuming suspended transaction");
}
Resume(status.Transaction, status.SuspendedResources);
}

View File

@@ -147,8 +147,8 @@ namespace Spring.Transaction.Support
if (val != null && LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Retrieved value [" + Describe(val) + "] for key [" + Describe(key) + "] bound to thread [" +
SystemUtils.ThreadId + "]");
LOG.LogDebug("Retrieved value [" + Describe(val) + "] for key [" + Describe(key) + "] bound to thread [" +
SystemUtils.ThreadId + "]");
}
return val;
}
@@ -178,8 +178,8 @@ namespace Spring.Transaction.Support
resources.Add(key, value);
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Bound value [" + Describe(value) + "] for key [" + Describe(key) + "] to thread [" +
SystemUtils.ThreadId + "]");
LOG.LogDebug("Bound value [" + Describe(value) + "] for key [" + Describe(key) + "] to thread [" +
SystemUtils.ThreadId + "]");
}
}
@@ -208,8 +208,8 @@ namespace Spring.Transaction.Support
}
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Removed value [" + Describe(val) + "] for key [" + Describe(key) + "] from thread [" +
SystemUtils.ThreadId + "]");
LOG.LogDebug("Removed value [" + Describe(val) + "] for key [" + Describe(key) + "] from thread [" +
SystemUtils.ThreadId + "]");
}
return val;
}
@@ -233,7 +233,7 @@ namespace Spring.Transaction.Support
}
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Initializing transaction synchronization");
LOG.LogDebug("Initializing transaction synchronization");
}
ArrayList syncs = new ArrayList();
LogicalThreadContext.SetData(syncsDataSlotName, syncs);
@@ -256,7 +256,7 @@ namespace Spring.Transaction.Support
}
if (LOG.IsEnabled(LogLevel.Debug))
{
LOG.Debug("Clearing transaction synchronization");
LOG.LogDebug("Clearing transaction synchronization");
}
LogicalThreadContext.FreeNamedDataSlot(syncsDataSlotName);
}

View File

@@ -200,7 +200,7 @@ namespace Spring.Transaction.Support
{
if (log.IsEnabled(LogLevel.Debug))
{
log.Debug("Initiating transaction rollback on application exception", exception);
log.LogDebug(exception, "Initiating transaction rollback on application exception");
}
try
{
@@ -208,7 +208,7 @@ namespace Spring.Transaction.Support
}
catch ( Exception ex )
{
log.Error("Application exception overridden by rollback exception", ex);
log.LogError(ex, "Application exception overridden by rollback exception");
throw;
}
}

View File

@@ -18,6 +18,7 @@
#endregion
using Microsoft.Extensions.Logging;
namespace Spring.Messaging.Ems.Common
{
@@ -195,7 +196,7 @@ namespace Spring.Messaging.Ems.Common
}
else
{
logger.Error("No exception handler registered with EmsConnection wrapper class.", arg.Exception);
logger.LogError((Exception) arg.Exception, "No exception handler registered with EmsConnection wrapper class.");
}
}
}

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