mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-05 00:47:21 +02:00
* Replace log4net by custom logger * WireMockNullLogger
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user