Replace log4net by custom logger (#94) (#96)

* Replace log4net by custom logger

* WireMockNullLogger
This commit is contained in:
Stef Heyenrath
2018-02-28 07:01:03 +00:00
committed by GitHub
parent e850126184
commit 938d3fb095
22 changed files with 236 additions and 52 deletions

View File

@@ -3,7 +3,7 @@ using WireMock.Server;
using WireMock.Settings;
using WireMock.Validation;
using JetBrains.Annotations;
using log4net;
using WireMock.Logging;
namespace WireMock.Net.StandAlone
{
@@ -12,8 +12,6 @@ namespace WireMock.Net.StandAlone
/// </summary>
public static class StandAloneApp
{
private static readonly ILog Log = LogManager.GetLogger(typeof(StandAloneApp));
/// <summary>
/// Start WireMock.Net standalone Server based on the FluentMockServerSettings.
/// </summary>
@@ -30,13 +28,12 @@ namespace WireMock.Net.StandAlone
/// Start WireMock.Net standalone Server based on the commandline arguments.
/// </summary>
/// <param name="args">The commandline arguments</param>
/// <param name="logger">The logger</param>
[PublicAPI]
public static FluentMockServer Start([NotNull] string[] args)
public static FluentMockServer Start([NotNull] string[] args, [CanBeNull] IWireMockLogger logger = null)
{
Check.NotNull(args, nameof(args));
Log.DebugFormat("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));
var parser = new SimpleCommandLineParser();
parser.Parse(args);
@@ -52,6 +49,11 @@ namespace WireMock.Net.StandAlone
RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"),
};
if (logger != null)
{
settings.Logger = logger;
}
if (parser.Contains("Port"))
{
settings.Port = parser.GetIntValue("Port");
@@ -74,9 +76,11 @@ namespace WireMock.Net.StandAlone
};
}
settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));
FluentMockServer server = Start(settings);
Log.InfoFormat("WireMock.Net server listening at {0}", string.Join(",", server.Urls));
settings.Logger.Info("WireMock.Net server listening at {0}", string.Join(",", server.Urls));
return server;
}

View File

@@ -36,7 +36,6 @@
<PackageReference Include="JetBrains.Annotations" Version="10.4.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="log4net" Version="2.0.8" />
</ItemGroup>
<ItemGroup>