Skip to content

Commit fda46d9

Browse files
authored
Switch to using MS logging abstractions (#267)
1 parent 2e6687a commit fda46d9

File tree

229 files changed

+1084
-898
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+1084
-898
lines changed

examples/Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<ItemGroup>
66
<PackageVersion Include="Apache.NMS" Version="2.0.0" />
77
<PackageVersion Include="Apache.NMS.ActiveMQ" Version="1.7.2" />
8-
<PackageVersion Include="Common.Logging" Version="3.4.1" />
9-
<PackageVersion Include="Common.Logging.Log4Net1213" Version="3.4.1" />
10-
<PackageVersion Include="Common.Logging.Log4Net1215" Version="3.4.1" />
8+
<PackageVersion Include="log4net" Version="3.0.4" />
9+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
10+
<PackageVersion Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
1111
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
1212
<PackageVersion Include="NUnit" Version="3.14.0" />
1313
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />

examples/Spring/Spring.Calculator/Spring.Calculator.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B1FF7E1F-9BF9-4EB3-B38C-39A0E3EA4D0A}"
66
ProjectSection(SolutionItems) = preProject
77
readme.txt = readme.txt
8-
SpringCalculator.snk = SpringCalculator.snk
98
EndProjectSection
109
EndProject
1110
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Calculator.Services.2010", "src\Spring.Calculator.Services\Spring.Calculator.Services.csproj", "{D9FB04E5-D636-4EC2-A3AB-FAB1C4F37827}"

examples/Spring/Spring.Calculator/src/Spring.Aspects/Logging/CommonLoggingAroundAdvice.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#region License
22

33
/*
4-
* Copyright © 2002-2011 the original author or authors.
5-
*
4+
* Copyright 2002-2011 the original author or authors.
5+
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
88
* You may obtain a copy of the License at
9-
*
9+
*
1010
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
11+
*
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@
2323
using System;
2424

2525
using AopAlliance.Intercept;
26-
using Common.Logging;
26+
using Microsoft.Extensions.Logging;
2727

2828
#endregion
2929

@@ -37,21 +37,21 @@ public class CommonLoggingAroundAdvice : IMethodInterceptor
3737
{
3838
#region Logging
3939

40-
private static readonly ILog LOG = LogManager.GetLogger(typeof(CommonLoggingAroundAdvice));
40+
private static readonly ILogger LOG = LogManager.GetLogger(typeof(CommonLoggingAroundAdvice));
4141

4242
#endregion
4343

4444
#region Fields
4545

46-
private LogLevel _level = LogLevel.All;
46+
private LogLevel _level = LogLevel.Trace;
4747

4848
#endregion
4949

5050
#region Properties
5151

5252
public LogLevel Level
5353
{
54-
get { return _level; }
54+
get { return _level; }
5555
set { _level = value; }
5656
}
5757

@@ -75,28 +75,28 @@ private void Log(string text, params object[] args)
7575
{
7676
switch(Level)
7777
{
78-
case LogLevel.All :
78+
case LogLevel.Trace :
7979
case LogLevel.Debug :
80-
if (LOG.IsDebugEnabled) LOG.Debug(String.Format(text, args));
80+
if (LOG.IsEnabled(LogLevel.Debug)) LOG.LogDebug(String.Format(text, args));
8181
break;
8282
case LogLevel.Error :
83-
if (LOG.IsErrorEnabled) LOG.Error(String.Format(text, args));
83+
if (LOG.IsEnabled(LogLevel.Error)) LOG.LogError(String.Format(text, args));
8484
break;
85-
case LogLevel.Fatal :
86-
if (LOG.IsFatalEnabled) LOG.Fatal(String.Format(text, args));
85+
case LogLevel.Critical :
86+
if (LOG.IsEnabled(LogLevel.Critical)) LOG.LogCritical(String.Format(text, args));
8787
break;
88-
case LogLevel.Info :
89-
if (LOG.IsInfoEnabled) LOG.Info(String.Format(text, args));
88+
case LogLevel.Information :
89+
if (LOG.IsEnabled(LogLevel.Information)) LOG.LogInformation(String.Format(text, args));
9090
break;
91-
case LogLevel.Warn :
92-
if (LOG.IsWarnEnabled) LOG.Warn(String.Format(text, args));
91+
case LogLevel.Warning:
92+
if (LOG.IsEnabled(LogLevel.Warning)) LOG.LogWarning(String.Format(text, args));
9393
break;
94-
case LogLevel.Off:
94+
case LogLevel.None:
9595
default :
9696
break;
9797
}
9898
}
9999

100100
#endregion
101101
}
102-
}
102+
}

examples/Spring/Spring.Calculator/src/Spring.Aspects/Spring.Aspects.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
</Reference>
1212
</ItemGroup>
1313
<ItemGroup>
14-
<PackageReference Include="Common.Logging" />
14+
<PackageReference Include="Microsoft.Extensions.Logging" />
1515
</ItemGroup>
1616
</Project>

examples/Spring/Spring.Calculator/src/Spring.Calculator.Web/Spring.Calculator.Web.csproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@
4545
<WarningLevel>4</WarningLevel>
4646
</PropertyGroup>
4747
<ItemGroup>
48-
<Reference Include="Common.Logging">
49-
<HintPath>..\..\..\..\..\lib\Net\2.0\Common.Logging.dll</HintPath>
50-
</Reference>
51-
<Reference Include="Common.Logging.Log4Net1211">
52-
<HintPath>..\..\..\..\..\lib\Net\2.0\Common.Logging.Log4Net1211.dll</HintPath>
53-
</Reference>
54-
<Reference Include="log4net">
55-
<HintPath>..\..\..\..\..\lib\Net\4.0\log4net.dll</HintPath>
56-
</Reference>
5748
<Reference Include="Spring.Aop">
5849
<HintPath>..\..\..\..\..\bin\net\4.0\debug\Spring.Aop.dll</HintPath>
5950
</Reference>

examples/Spring/Spring.CodeConfig.Migration/src/SpringApp/SpringApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ProjectReference Include="..\Primes\Primes.csproj" />
88
</ItemGroup>
99
<ItemGroup>
10-
<PackageReference Include="Common.Logging" />
10+
<PackageReference Include="Microsoft.Extensions.Logging" />
1111
<Reference Include="System.Configuration" />
1212
</ItemGroup>
1313
<ItemGroup>

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FedExShippingService.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
#region Imports
2222

23-
using System;
24-
25-
using Common.Logging;
26-
23+
using Microsoft.Extensions.Logging;
2724
using Spring.Northwind.Domain;
2825

2926
#endregion
@@ -32,11 +29,11 @@ namespace Spring.Northwind.Service
3229
{
3330
public class FedExShippingService : IShippingService
3431
{
35-
protected static readonly ILog log = LogManager.GetLogger(typeof (FedExShippingService));
32+
protected static readonly ILogger log = LogManager.GetLogger(typeof (FedExShippingService));
3633

3734
public void ShipOrder(Order order)
3835
{
3936
log.Info("Shipping order id = " + order.Id);
4037
}
4138
}
42-
}
39+
}

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
#region Imports
2222

2323
using System;
24-
using System.Collections;
25-
26-
using Common.Logging;
2724

25+
using Microsoft.Extensions.Logging;
2826
using Spring.Transaction.Interceptor;
2927

3028
using Spring.Northwind.Dao;
@@ -38,7 +36,7 @@ public class FulfillmentService : IFulfillmentService
3836
{
3937
#region Fields
4038

41-
private static readonly ILog log = LogManager.GetLogger(typeof (FulfillmentService));
39+
private static readonly ILogger log = LogManager.GetLogger(typeof (FulfillmentService));
4240

4341
private IProductDao productDao;
4442

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/FulfillmentResult.aspx.cs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
using System;
2-
using System.IO;
3-
4-
using log4net.Appender;
5-
using log4net.Core;
6-
using log4net.Layout;
7-
using log4net.Repository;
8-
92
using Spring.Northwind.Service;
10-
using Spring.Web.UI;
11-
12-
using LogManager=log4net.LogManager;
133

144
public partial class FullfillmentResult : ConversationPage
155
{
@@ -28,36 +18,8 @@ public ICustomerEditController CustomerEditController
2818

2919
protected void Page_Load(object sender, EventArgs e)
3020
{
31-
// gather log4net output with small hack to get results...
32-
ILoggerRepository repository = LogManager.GetRepository();
33-
IAppender[] appenders = repository.GetAppenders();
34-
MemoryAppender appender = null;
35-
foreach (IAppender a in appenders)
36-
{
37-
if (a is MemoryAppender)
38-
{
39-
// we found our appender to look results from
40-
appender = a as MemoryAppender;
41-
break;
42-
}
43-
}
44-
45-
if (appender != null)
46-
{
47-
appender.Clear();
48-
fulfillmentService.ProcessCustomer(customerEditController.CurrentCustomer.Id);
49-
LoggingEvent[] events = appender.GetEvents();
50-
StringWriter stringWriter = new StringWriter();
51-
PatternLayout layout = new PatternLayout("%date{HH:mm:ss} %-5level %logger{1}: %message<br />");
52-
foreach (LoggingEvent loggingEvent in events)
53-
{
54-
layout.Format(stringWriter, loggingEvent);
55-
}
56-
57-
results.Text = stringWriter.ToString();
58-
}
59-
6021
}
22+
6123
protected void customerOrders_Click(object sender, EventArgs e)
6224
{
6325
SetResult("Back");

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.Conversation/Spring.Northwind.Web.Conversation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<WarningLevel>4</WarningLevel>
4343
</PropertyGroup>
4444
<ItemGroup>
45-
<PackageReference Include="Common.Logging.Log4Net1213" />
45+
<PackageReference Include="Microsoft.Extensions.Logging" />
4646
</ItemGroup>
4747
<ItemGroup>
4848
<Reference Include="System" />

0 commit comments

Comments
 (0)