Skip to content

Commit 25fec30

Browse files
authored
Merge pull request #87 from hsaito/maint
Misc maintenance
2 parents 3b396d4 + c191ccd commit 25fec30

7 files changed

Lines changed: 25 additions & 89 deletions

File tree

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

MyNumberNET/MyNumberNET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<Authors>Hideki Saito</Authors>
55
<Company>Hideki Saito</Company>
66
<Title>MyNumberNET My Number Validation Library</Title>
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Authors>Hideki Saito</Authors>
66
<Company>Hideki Saito</Company>
77
<Title>MyNumber My Number Validation Command Line Tool</Title>
@@ -14,24 +14,17 @@
1414
<Version>1.0.4.0</Version>
1515
<AssemblyVersion>1.0.4.0</AssemblyVersion>
1616
<FileVersion>1.0.4.0</FileVersion>
17-
<RuntimeIdentifiers>linux-x64,linux-arm,win-x64,win-x86,osx-x64</RuntimeIdentifiers>
1817
<LangVersion>latest</LangVersion>
1918
</PropertyGroup>
2019
<ItemGroup>
21-
<None Update="log4net.config">
20+
<None Update="nlog.config">
2221
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2322
</None>
2423
</ItemGroup>
2524
<ItemGroup>
26-
<PackageReference Include="log4net" Version="2.0.10" />
27-
<PackageReference Include="System.Console" Version="4.3.1" />
28-
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
25+
<PackageReference Include="NLog" Version="6.0.3" />
2926
</ItemGroup>
3027
<ItemGroup>
3128
<ProjectReference Include="..\MyNumberNET\MyNumberNET.csproj" />
3229
</ItemGroup>
33-
<PropertyGroup>
34-
<OutputType>Exe</OutputType>
35-
<TargetFramework>netcoreapp2.1</TargetFramework>
36-
</PropertyGroup>
3730
</Project>

MyNumberNET_CLI/Program.cs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,25 @@
44
using System.Reflection;
55
using System.Text.RegularExpressions;
66
using System.Xml;
7-
using log4net;
8-
using log4net.Config;
9-
using log4net.Repository.Hierarchy;
7+
using NLog;
108
using MyNumberNET;
119
using static System.Char;
1210

1311
namespace MyNumberNET_CLI
1412
{
1513
public class Program
1614
{
17-
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
15+
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
1816

1917
public static int Main(string[] args)
2018
{
2119
try
2220
{
23-
var result = InitializeLogging();
24-
if (!result)
25-
throw new Exception("Logging could not be enabled.");
21+
// NLog automatically loads nlog.config, no manual initialization needed
2622
}
2723
catch (Exception ex)
2824
{
29-
Log.Fatal(ex.Message);
25+
Log.Fatal(ex, ex.Message);
3026
return -1;
3127
}
3228

@@ -183,8 +179,7 @@ public static int Main(string[] args)
183179
}
184180
catch (Exception ex)
185181
{
186-
Log.Fatal(ex.Message);
187-
Log.Debug(ex.StackTrace);
182+
Log.Fatal(ex, ex.Message);
188183
return -1;
189184
}
190185
}
@@ -379,32 +374,6 @@ private static int[] Increment(int[] input)
379374
return input;
380375
}
381376

382-
/// <summary>
383-
/// Initialize logging
384-
/// </summary>
385-
private static bool InitializeLogging()
386-
{
387-
try
388-
{
389-
// Configuration for logging
390-
var log4NetConfig = new XmlDocument();
391-
392-
using (var reader = new StreamReader(new FileStream("log4net.config", FileMode.Open, FileAccess.Read)))
393-
{
394-
log4NetConfig.Load(reader);
395-
}
396-
397-
var rep = LogManager.CreateRepository(Assembly.GetEntryAssembly(), typeof(Hierarchy));
398-
XmlConfigurator.Configure(rep, log4NetConfig["log4net"]);
399-
return true;
400-
}
401-
catch (Exception ex)
402-
{
403-
Console.WriteLine("Error initializing the logging.");
404-
Console.WriteLine(ex.Message);
405-
return false;
406-
}
407-
}
408377

409378
private enum RangeMode
410379
{

MyNumberNET_CLI/log4net.config

Lines changed: 0 additions & 30 deletions
This file was deleted.

MyNumberNET_CLI/nlog.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<targets>
5+
<target xsi:type="File" name="logfile" fileName="${basedir}/log.txt" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
6+
<target xsi:type="Console" name="logconsole" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
7+
</targets>
8+
<rules>
9+
<logger name="*" minlevel="Info" writeTo="logconsole,logfile" />
10+
</rules>
11+
</nlog>
12+

MyNumberNET_Test/MyNumberNET_Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<Authors>Hideki Saito</Authors>
66
<Company>Hideki Saito</Company>
@@ -17,9 +17,9 @@
1717
<LangVersion>latest</LangVersion>
1818
</PropertyGroup>
1919
<ItemGroup>
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
21-
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
22-
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
21+
<PackageReference Include="MSTest.TestAdapter" Version="3.10.2" />
22+
<PackageReference Include="MSTest.TestFramework" Version="3.10.2" />
2323
</ItemGroup>
2424
<ItemGroup>
2525
<ProjectReference Include="..\MyNumberNET\MyNumberNET.csproj" />

0 commit comments

Comments
 (0)