Browse Source

Refactor logging to allow a loggerfactory per session (#1673)

* Refactor logging to allow a loggerfactory per session specified in the ConnectionInfo.

This commit introduces an `ILoggerFactory` to various classes, replacing the static logger factory with an instance-based approach for more flexible and session-specific logging. These changes improve the logging framework's flexibility and maintainability and allow unit testing of logging.

* Improvements bases on feedback. Fixed tests. Added documentation.

* Update src/Renci.SshNet/ConnectionInfo.cs

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Bart Vries 3 months ago
parent
commit
d40bc43ac1
100 changed files with 311 additions and 64 deletions
  1. 25 1
      docfx/logging.md
  2. 1 1
      src/Renci.SshNet/BaseClient.cs
  3. 1 1
      src/Renci.SshNet/Channels/Channel.cs
  4. 1 1
      src/Renci.SshNet/Channels/ChannelDirectTcpip.cs
  5. 1 1
      src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs
  6. 2 2
      src/Renci.SshNet/Connection/ConnectorBase.cs
  7. 4 2
      src/Renci.SshNet/Connection/DirectConnector.cs
  8. 4 2
      src/Renci.SshNet/Connection/HttpConnector.cs
  9. 4 2
      src/Renci.SshNet/Connection/ProxyConnector.cs
  10. 4 2
      src/Renci.SshNet/Connection/Socks4Connector.cs
  11. 4 2
      src/Renci.SshNet/Connection/Socks5Connector.cs
  12. 10 0
      src/Renci.SshNet/ConnectionInfo.cs
  13. 6 3
      src/Renci.SshNet/ForwardedPortDynamic.cs
  14. 6 3
      src/Renci.SshNet/ForwardedPortLocal.cs
  15. 6 3
      src/Renci.SshNet/ForwardedPortRemote.cs
  16. 10 0
      src/Renci.SshNet/IConnectionInfo.cs
  17. 10 0
      src/Renci.SshNet/ISession.cs
  18. 10 0
      src/Renci.SshNet/ISubsystemSession.cs
  19. 2 2
      src/Renci.SshNet/Security/KeyExchange.cs
  20. 7 8
      src/Renci.SshNet/ServiceFactory.cs
  21. 10 1
      src/Renci.SshNet/Session.cs
  22. 1 1
      src/Renci.SshNet/Sftp/SftpFileReader.cs
  23. 10 9
      src/Renci.SshNet/SubsystemSession.cs
  24. 4 1
      test/Renci.SshNet.Tests/Classes/BaseClientTestBase.cs
  25. 2 0
      test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs
  26. 3 1
      test/Renci.SshNet.Tests/Classes/BaseClientTest_Disconnected_Connect.cs
  27. 2 0
      test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs
  28. 2 0
      test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
  29. 2 0
      test/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
  30. 3 1
      test/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTestBase.cs
  31. 3 1
      test/Renci.SshNet.Tests/Classes/Channels/ChannelTestBase.cs
  32. 2 0
      test/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenConfirmationReceived_OnOpenConfirmation_Exception.cs
  33. 2 0
      test/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenFailureReceived_OnOpenFailure_Exception.cs
  34. 3 1
      test/Renci.SshNet.Tests/Classes/ClientAuthenticationTestBase.cs
  35. 4 2
      test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTestBase.cs
  36. 4 2
      test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTestBase.cs
  37. 3 1
      test/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTestBase.cs
  38. 3 1
      test/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTestBase.cs
  39. 3 1
      test/Renci.SshNet.Tests/Classes/ConnectionInfoTest_Authenticate_Failure.cs
  40. 3 1
      test/Renci.SshNet.Tests/Classes/ConnectionInfoTest_Authenticate_Success.cs
  41. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortNeverStarted.cs
  42. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelBound.cs
  43. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs
  44. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStopped.cs
  45. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_SessionErrorOccurred_ChannelBound.cs
  46. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortNeverStarted.cs
  47. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStarted.cs
  48. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStopped.cs
  49. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_SessionNotConnected.cs
  50. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketSendShutdownImmediately.cs
  51. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketVersionNotSupported.cs
  52. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs
  53. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs
  54. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStopped.cs
  55. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed.cs
  56. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortNeverStarted.cs
  57. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelBound.cs
  58. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelNotBound.cs
  59. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStopped.cs
  60. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortNeverStarted.cs
  61. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStarted.cs
  62. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStopped.cs
  63. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_SessionNotConnected.cs
  64. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_SessionNull.cs
  65. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortNeverStarted.cs
  66. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelBound.cs
  67. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelNotBound.cs
  68. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs
  69. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortNeverStarted.cs
  70. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStarted_ChannelBound.cs
  71. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStopped.cs
  72. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortNeverStarted.cs
  73. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortStarted.cs
  74. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortStopped.cs
  75. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_SessionNotConnected.cs
  76. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Started.cs
  77. 2 0
      test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortNeverStarted.cs
  78. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateConnector.cs
  79. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateSftpFileReader_EndLStatThrowsSshException.cs
  80. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException.cs
  81. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestReturnsFalse.cs
  82. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestThrowsException.cs
  83. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendShellRequestReturnsFalse.cs
  84. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendShellRequestThrowsException.cs
  85. 2 0
      test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_Success.cs
  86. 2 1
      test/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
  87. 2 1
      test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerAndClientDisconnectRace.cs
  88. 2 1
      test/Renci.SshNet.Tests/Classes/SessionTest_ConnectingBase.cs
  89. 2 1
      test/Renci.SshNet.Tests/Classes/SessionTest_SocketConnected_BadPacketAndDispose.cs
  90. 2 0
      test/Renci.SshNet.Tests/Classes/Sftp/SftpFileReaderTestBase.cs
  91. 2 0
      test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_Connected_RequestRead.cs
  92. 2 0
      test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_Connected_RequestStatVfs.cs
  93. 2 0
      test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_DataReceived_MultipleSftpMessagesInSingleSshDataMessage.cs
  94. 2 0
      test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_DataReceived_MultipleSftpMessagesSplitOverMultipleSshDataMessages.cs
  95. 2 0
      test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_DataReceived_SingleSftpMessageInSshDataMessage.cs
  96. 4 0
      test/Renci.SshNet.Tests/Classes/SftpClientTest.UploadFile.cs
  97. 4 0
      test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs
  98. 2 0
      test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs
  99. 2 0
      test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs
  100. 2 0
      test/Renci.SshNet.Tests/Classes/ShellStreamTest_Write_WriteBufferEmptyAndWriteMoreBytesThanBufferSize.cs

+ 25 - 1
docfx/logging.md

@@ -1,7 +1,31 @@
 Logging
 Logging
 =================
 =================
 
 
-SSH.NET uses the [Microsoft.Extensions.Logging](https://learn.microsoft.com/dotnet/core/extensions/logging) API to log diagnostic messages. In order to access the log messages of SSH.NET in your own application for diagnosis, register your own `ILoggerFactory` before using the SSH.NET APIs, for example:
+SSH.NET uses the [Microsoft.Extensions.Logging](https://learn.microsoft.com/dotnet/core/extensions/logging) API to log diagnostic messages. 
+
+It is possible to specify a logger in the `ConnectionInfo`, for example:
+
+```cs
+using Microsoft.Extensions.Logging;
+
+ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
+{
+    builder.SetMinimumLevel(LogLevel.Debug);
+    builder.AddConsole();
+});
+
+var connectionInfo = new ConnectionInfo("sftp.foo.com",
+                                        "guest",
+                                        new PasswordAuthenticationMethod("guest", "pwd"));
+										
+connectionInfo.LoggerFactory = loggerFactory;
+using (var client = new SftpClient(connectionInfo))
+{
+    client.Connect();
+}
+```
+
+You can also register an application-wide `ILoggerFactory` before using the SSH.NET APIs, this will be used as a fallback if the `ConnectionInfo` is not set, for example:
 
 
 ```cs
 ```cs
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Logging;

+ 1 - 1
src/Renci.SshNet/BaseClient.cs

@@ -192,7 +192,7 @@ namespace Renci.SshNet
             _connectionInfo = connectionInfo;
             _connectionInfo = connectionInfo;
             _ownsConnectionInfo = ownsConnectionInfo;
             _ownsConnectionInfo = ownsConnectionInfo;
             _serviceFactory = serviceFactory;
             _serviceFactory = serviceFactory;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
+            _logger = (connectionInfo.LoggerFactory ?? SshNetLoggingConfiguration.LoggerFactory).CreateLogger(GetType());
             _keepAliveInterval = Timeout.InfiniteTimeSpan;
             _keepAliveInterval = Timeout.InfiniteTimeSpan;
         }
         }
 
 

+ 1 - 1
src/Renci.SshNet/Channels/Channel.cs

@@ -84,7 +84,7 @@ namespace Renci.SshNet.Channels
             LocalChannelNumber = localChannelNumber;
             LocalChannelNumber = localChannelNumber;
             LocalPacketSize = localPacketSize;
             LocalPacketSize = localPacketSize;
             LocalWindowSize = localWindowSize;
             LocalWindowSize = localWindowSize;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
+            _logger = session.SessionLoggerFactory.CreateLogger(GetType());
 
 
             session.ChannelWindowAdjustReceived += OnChannelWindowAdjust;
             session.ChannelWindowAdjustReceived += OnChannelWindowAdjust;
             session.ChannelDataReceived += OnChannelData;
             session.ChannelDataReceived += OnChannelData;

+ 1 - 1
src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

@@ -33,7 +33,7 @@ namespace Renci.SshNet.Channels
         public ChannelDirectTcpip(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
         public ChannelDirectTcpip(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
             : base(session, localChannelNumber, localWindowSize, localPacketSize)
             : base(session, localChannelNumber, localWindowSize, localPacketSize)
         {
         {
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<ChannelDirectTcpip>();
+            _logger = session.SessionLoggerFactory.CreateLogger<ChannelDirectTcpip>();
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 1 - 1
src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs

@@ -48,7 +48,7 @@ namespace Renci.SshNet.Channels
                    remoteWindowSize,
                    remoteWindowSize,
                    remotePacketSize)
                    remotePacketSize)
         {
         {
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<ChannelForwardedTcpip>();
+            _logger = session.SessionLoggerFactory.CreateLogger<ChannelForwardedTcpip>();
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 2 - 2
src/Renci.SshNet/Connection/ConnectorBase.cs

@@ -16,12 +16,12 @@ namespace Renci.SshNet.Connection
     {
     {
         private readonly ILogger _logger;
         private readonly ILogger _logger;
 
 
-        protected ConnectorBase(ISocketFactory socketFactory)
+        protected ConnectorBase(ISocketFactory socketFactory, ILoggerFactory loggerFactory)
         {
         {
             ThrowHelper.ThrowIfNull(socketFactory);
             ThrowHelper.ThrowIfNull(socketFactory);
 
 
             SocketFactory = socketFactory;
             SocketFactory = socketFactory;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
+            _logger = loggerFactory.CreateLogger(GetType());
         }
         }
 
 
         internal ISocketFactory SocketFactory { get; private set; }
         internal ISocketFactory SocketFactory { get; private set; }

+ 4 - 2
src/Renci.SshNet/Connection/DirectConnector.cs

@@ -2,12 +2,14 @@
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging;
+
 namespace Renci.SshNet.Connection
 namespace Renci.SshNet.Connection
 {
 {
     internal sealed class DirectConnector : ConnectorBase
     internal sealed class DirectConnector : ConnectorBase
     {
     {
-        public DirectConnector(ISocketFactory socketFactory)
-            : base(socketFactory)
+        public DirectConnector(ISocketFactory socketFactory, ILoggerFactory loggerFactory)
+            : base(socketFactory, loggerFactory)
         {
         {
         }
         }
 
 

+ 4 - 2
src/Renci.SshNet/Connection/HttpConnector.cs

@@ -5,6 +5,8 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Abstractions;
 using Renci.SshNet.Abstractions;
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 
 
@@ -48,8 +50,8 @@ namespace Renci.SshNet.Connection
         private static readonly Regex HttpHeaderRegex = new Regex(HttpHeaderPattern, RegexOptions.Compiled);
         private static readonly Regex HttpHeaderRegex = new Regex(HttpHeaderPattern, RegexOptions.Compiled);
 #endif
 #endif
 
 
-        public HttpConnector(ISocketFactory socketFactory)
-            : base(socketFactory)
+        public HttpConnector(ISocketFactory socketFactory, ILoggerFactory loggerFactory)
+            : base(socketFactory, loggerFactory)
         {
         {
         }
         }
 
 

+ 4 - 2
src/Renci.SshNet/Connection/ProxyConnector.cs

@@ -4,6 +4,8 @@ using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
+using Microsoft.Extensions.Logging;
+
 namespace Renci.SshNet.Connection
 namespace Renci.SshNet.Connection
 {
 {
     /// <summary>
     /// <summary>
@@ -12,8 +14,8 @@ namespace Renci.SshNet.Connection
     /// </summary>
     /// </summary>
     internal abstract class ProxyConnector : ConnectorBase
     internal abstract class ProxyConnector : ConnectorBase
     {
     {
-        protected ProxyConnector(ISocketFactory socketFactory)
-            : base(socketFactory)
+        protected ProxyConnector(ISocketFactory socketFactory, ILoggerFactory loggerFactory)
+            : base(socketFactory, loggerFactory)
         {
         {
         }
         }
 
 

+ 4 - 2
src/Renci.SshNet/Connection/Socks4Connector.cs

@@ -4,6 +4,8 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Abstractions;
 using Renci.SshNet.Abstractions;
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 
 
@@ -17,8 +19,8 @@ namespace Renci.SshNet.Connection
     /// </remarks>
     /// </remarks>
     internal sealed class Socks4Connector : ProxyConnector
     internal sealed class Socks4Connector : ProxyConnector
     {
     {
-        public Socks4Connector(ISocketFactory socketFactory)
-            : base(socketFactory)
+        public Socks4Connector(ISocketFactory socketFactory, ILoggerFactory loggerFactory)
+            : base(socketFactory, loggerFactory)
         {
         {
         }
         }
 
 

+ 4 - 2
src/Renci.SshNet/Connection/Socks5Connector.cs

@@ -5,6 +5,8 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Abstractions;
 using Renci.SshNet.Abstractions;
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 
 
@@ -18,8 +20,8 @@ namespace Renci.SshNet.Connection
     /// </remarks>
     /// </remarks>
     internal sealed class Socks5Connector : ProxyConnector
     internal sealed class Socks5Connector : ProxyConnector
     {
     {
-        public Socks5Connector(ISocketFactory socketFactory)
-            : base(socketFactory)
+        public Socks5Connector(ISocketFactory socketFactory, ILoggerFactory loggerFactory)
+            : base(socketFactory, loggerFactory)
         {
         {
         }
         }
 
 

+ 10 - 0
src/Renci.SshNet/ConnectionInfo.cs

@@ -5,6 +5,8 @@ using System.Net;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 using Renci.SshNet.Compression;
 using Renci.SshNet.Compression;
 using Renci.SshNet.Messages.Authentication;
 using Renci.SshNet.Messages.Authentication;
@@ -495,5 +497,13 @@ namespace Renci.SshNet
             get { return AuthenticationMethods.Cast<IAuthenticationMethod>().ToList(); }
             get { return AuthenticationMethods.Cast<IAuthenticationMethod>().ToList(); }
 #pragma warning restore S2365 // Properties should not make collection or array copies
 #pragma warning restore S2365 // Properties should not make collection or array copies
         }
         }
+
+        /// <summary>
+        /// Gets or sets logger factory for this connection.
+        /// </summary>
+        /// <value>
+        /// The logger factory for this connection. If <see langword="null"/> then <see cref="SshNetLoggingConfiguration.LoggerFactory"/> is used.
+        /// </value>
+        public ILoggerFactory LoggerFactory { get; set; }
     }
     }
 }
 }

+ 6 - 3
src/Renci.SshNet/ForwardedPortDynamic.cs

@@ -21,7 +21,6 @@ namespace Renci.SshNet
     /// </summary>
     /// </summary>
     public class ForwardedPortDynamic : ForwardedPort
     public class ForwardedPortDynamic : ForwardedPort
     {
     {
-        private readonly ILogger _logger;
         private ForwardedPortStatus _status;
         private ForwardedPortStatus _status;
 
 
         /// <summary>
         /// <summary>
@@ -75,7 +74,6 @@ namespace Renci.SshNet
             BoundHost = host;
             BoundHost = host;
             BoundPort = port;
             BoundPort = port;
             _status = ForwardedPortStatus.Stopped;
             _status = ForwardedPortStatus.Stopped;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<ForwardedPortDynamic>();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -416,7 +414,12 @@ namespace Renci.SshNet
 
 
             if (!_pendingChannelCountdown.Wait(timeout))
             if (!_pendingChannelCountdown.Wait(timeout))
             {
             {
-                _logger.LogInformation("Timeout waiting for pending channels in dynamic forwarded port to close.");
+                var session = Session;
+                if (session != null)
+                {
+                    var logger = session.SessionLoggerFactory.CreateLogger<ForwardedPortDynamic>();
+                    logger.LogInformation("Timeout waiting for pending channels in dynamic forwarded port to close.");
+                }
             }
             }
         }
         }
 
 

+ 6 - 3
src/Renci.SshNet/ForwardedPortLocal.cs

@@ -14,7 +14,6 @@ namespace Renci.SshNet
     /// </summary>
     /// </summary>
     public partial class ForwardedPortLocal : ForwardedPort
     public partial class ForwardedPortLocal : ForwardedPort
     {
     {
-        private readonly ILogger _logger;
         private ForwardedPortStatus _status;
         private ForwardedPortStatus _status;
         private bool _isDisposed;
         private bool _isDisposed;
         private Socket _listener;
         private Socket _listener;
@@ -103,7 +102,6 @@ namespace Renci.SshNet
             Host = host;
             Host = host;
             Port = port;
             Port = port;
             _status = ForwardedPortStatus.Stopped;
             _status = ForwardedPortStatus.Stopped;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<ForwardedPortLocal>();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -390,7 +388,12 @@ namespace Renci.SshNet
 
 
             if (!_pendingChannelCountdown.Wait(timeout))
             if (!_pendingChannelCountdown.Wait(timeout))
             {
             {
-                _logger.LogInformation("Timeout waiting for pending channels in local forwarded port to close.");
+                var session = Session;
+                if (session != null)
+                {
+                    var logger = session.SessionLoggerFactory.CreateLogger<ForwardedPortLocal>();
+                    logger.LogInformation("Timeout waiting for pending channels in local forwarded port to close.");
+                }
             }
             }
         }
         }
 
 

+ 6 - 3
src/Renci.SshNet/ForwardedPortRemote.cs

@@ -16,7 +16,6 @@ namespace Renci.SshNet
     /// </summary>
     /// </summary>
     public class ForwardedPortRemote : ForwardedPort
     public class ForwardedPortRemote : ForwardedPort
     {
     {
-        private readonly ILogger _logger;
         private ForwardedPortStatus _status;
         private ForwardedPortStatus _status;
         private bool _requestStatus;
         private bool _requestStatus;
         private EventWaitHandle _globalRequestResponse = new AutoResetEvent(initialState: false);
         private EventWaitHandle _globalRequestResponse = new AutoResetEvent(initialState: false);
@@ -100,7 +99,6 @@ namespace Renci.SshNet
             HostAddress = hostAddress;
             HostAddress = hostAddress;
             Port = port;
             Port = port;
             _status = ForwardedPortStatus.Stopped;
             _status = ForwardedPortStatus.Stopped;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<ForwardedPortRemote>();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -212,7 +210,12 @@ namespace Renci.SshNet
 
 
             if (!_pendingChannelCountdown.Wait(timeout))
             if (!_pendingChannelCountdown.Wait(timeout))
             {
             {
-                _logger.LogInformation("Timeout waiting for pending channels in remote forwarded port to close.");
+                var session = Session;
+                if (session != null)
+                {
+                    var logger = session.SessionLoggerFactory.CreateLogger<ForwardedPortRemote>();
+                    logger.LogInformation("Timeout waiting for pending channels in remote forwarded port to close.");
+                }
             }
             }
 
 
             _status = ForwardedPortStatus.Stopped;
             _status = ForwardedPortStatus.Stopped;

+ 10 - 0
src/Renci.SshNet/IConnectionInfo.cs

@@ -2,6 +2,8 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 using Renci.SshNet.Messages.Connection;
 using Renci.SshNet.Messages.Connection;
 
 
@@ -12,6 +14,14 @@ namespace Renci.SshNet
     /// </summary>
     /// </summary>
     internal interface IConnectionInfo
     internal interface IConnectionInfo
     {
     {
+        /// <summary>
+        /// Gets the logger factory for this connection.
+        /// </summary>
+        /// <value>
+        /// The logger factory for this connection. If <see langword="null"/> then <see cref="SshNetLoggingConfiguration.LoggerFactory"/> is used.
+        /// </value>
+        public ILoggerFactory LoggerFactory { get; }
+
         /// <summary>
         /// <summary>
         /// Gets the timeout to used when waiting for a server to acknowledge closing a channel.
         /// Gets the timeout to used when waiting for a server to acknowledge closing a channel.
         /// </summary>
         /// </summary>

+ 10 - 0
src/Renci.SshNet/ISession.cs

@@ -3,6 +3,8 @@ using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Channels;
 using Renci.SshNet.Channels;
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 using Renci.SshNet.Messages;
 using Renci.SshNet.Messages;
@@ -22,6 +24,14 @@ namespace Renci.SshNet
         /// <value>The connection info.</value>
         /// <value>The connection info.</value>
         IConnectionInfo ConnectionInfo { get; }
         IConnectionInfo ConnectionInfo { get; }
 
 
+        /// <summary>
+        /// Gets the logger factory for this session.
+        /// </summary>
+        /// <value>
+        /// The logger factory for this session. Will never return <see langword="null"/>.
+        /// </value>
+        public ILoggerFactory SessionLoggerFactory { get; }
+
         /// <summary>
         /// <summary>
         /// Gets a value indicating whether the session is connected.
         /// Gets a value indicating whether the session is connected.
         /// </summary>
         /// </summary>

+ 10 - 0
src/Renci.SshNet/ISubsystemSession.cs

@@ -1,6 +1,8 @@
 using System;
 using System;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging;
+
 using Renci.SshNet.Common;
 using Renci.SshNet.Common;
 
 
 namespace Renci.SshNet
 namespace Renci.SshNet
@@ -10,6 +12,14 @@ namespace Renci.SshNet
     /// </summary>
     /// </summary>
     internal interface ISubsystemSession : IDisposable
     internal interface ISubsystemSession : IDisposable
     {
     {
+        /// <summary>
+        /// Gets the logger factory for this subsystem session.
+        /// </summary>
+        /// <value>
+        /// The logger factory for this connection. Will never return <see langword="null"/>.
+        /// </value>
+        public ILoggerFactory SessionLoggerFactory { get; }
+
         /// <summary>
         /// <summary>
         /// Gets or sets the number of milliseconds to wait for an operation to complete.
         /// Gets or sets the number of milliseconds to wait for an operation to complete.
         /// </summary>
         /// </summary>

+ 2 - 2
src/Renci.SshNet/Security/KeyExchange.cs

@@ -18,7 +18,7 @@ namespace Renci.SshNet.Security
     /// </summary>
     /// </summary>
     public abstract class KeyExchange : Algorithm, IKeyExchange
     public abstract class KeyExchange : Algorithm, IKeyExchange
     {
     {
-        private readonly ILogger _logger;
+        private ILogger _logger;
         private Func<byte[], KeyHostAlgorithm> _hostKeyAlgorithmFactory;
         private Func<byte[], KeyHostAlgorithm> _hostKeyAlgorithmFactory;
         private CipherInfo _clientCipherInfo;
         private CipherInfo _clientCipherInfo;
         private CipherInfo _serverCipherInfo;
         private CipherInfo _serverCipherInfo;
@@ -69,13 +69,13 @@ namespace Renci.SshNet.Security
         /// </summary>
         /// </summary>
         protected KeyExchange()
         protected KeyExchange()
         {
         {
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
         public virtual void Start(Session session, KeyExchangeInitMessage message, bool sendClientInitMessage)
         public virtual void Start(Session session, KeyExchangeInitMessage message, bool sendClientInitMessage)
         {
         {
             Session = session;
             Session = session;
+            _logger = Session.SessionLoggerFactory.CreateLogger(GetType());
 
 
             if (sendClientInitMessage)
             if (sendClientInitMessage)
             {
             {

+ 7 - 8
src/Renci.SshNet/ServiceFactory.cs

@@ -26,11 +26,8 @@ namespace Renci.SshNet
         /// </summary>
         /// </summary>
         private const int PartialSuccessLimit = 5;
         private const int PartialSuccessLimit = 5;
 
 
-        private readonly ILogger _logger;
-
         internal ServiceFactory()
         internal ServiceFactory()
         {
         {
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<ServiceFactory>();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -160,7 +157,7 @@ namespace Renci.SshNet
                 fileSize = null;
                 fileSize = null;
                 maxPendingReads = defaultMaxPendingReads;
                 maxPendingReads = defaultMaxPendingReads;
 
 
-                _logger.LogInformation(ex, "Failed to obtain size of file. Allowing maximum {MaxPendingReads} pending reads", maxPendingReads);
+                sftpSession.SessionLoggerFactory.CreateLogger<ServiceFactory>().LogInformation(ex, "Failed to obtain size of file. Allowing maximum {MaxPendingReads} pending reads", maxPendingReads);
             }
             }
 
 
             return sftpSession.CreateFileReader(handle, sftpSession, chunkSize, maxPendingReads, fileSize);
             return sftpSession.CreateFileReader(handle, sftpSession, chunkSize, maxPendingReads, fileSize);
@@ -221,16 +218,18 @@ namespace Renci.SshNet
             ThrowHelper.ThrowIfNull(connectionInfo);
             ThrowHelper.ThrowIfNull(connectionInfo);
             ThrowHelper.ThrowIfNull(socketFactory);
             ThrowHelper.ThrowIfNull(socketFactory);
 
 
+            var loggerFactory = connectionInfo.LoggerFactory ?? SshNetLoggingConfiguration.LoggerFactory;
+
             switch (connectionInfo.ProxyType)
             switch (connectionInfo.ProxyType)
             {
             {
                 case ProxyTypes.None:
                 case ProxyTypes.None:
-                    return new DirectConnector(socketFactory);
+                    return new DirectConnector(socketFactory, loggerFactory);
                 case ProxyTypes.Socks4:
                 case ProxyTypes.Socks4:
-                    return new Socks4Connector(socketFactory);
+                    return new Socks4Connector(socketFactory, loggerFactory);
                 case ProxyTypes.Socks5:
                 case ProxyTypes.Socks5:
-                    return new Socks5Connector(socketFactory);
+                    return new Socks5Connector(socketFactory, loggerFactory);
                 case ProxyTypes.Http:
                 case ProxyTypes.Http:
-                    return new HttpConnector(socketFactory);
+                    return new HttpConnector(socketFactory, loggerFactory);
                 default:
                 default:
                     throw new NotSupportedException(string.Format("ProxyTypes '{0}' is not supported.", connectionInfo.ProxyType));
                     throw new NotSupportedException(string.Format("ProxyTypes '{0}' is not supported.", connectionInfo.ProxyType));
             }
             }

+ 10 - 1
src/Renci.SshNet/Session.cs

@@ -352,6 +352,14 @@ namespace Renci.SshNet
         /// </value>
         /// </value>
         public ConnectionInfo ConnectionInfo { get; private set; }
         public ConnectionInfo ConnectionInfo { get; private set; }
 
 
+        /// <summary>
+        /// Gets the logger factory for this session.
+        /// </summary>
+        /// <value>
+        /// The logger factory for this session.
+        /// </value>
+        public ILoggerFactory SessionLoggerFactory { get; }
+
         /// <summary>
         /// <summary>
         /// Occurs when an error occurred.
         /// Occurs when an error occurred.
         /// </summary>
         /// </summary>
@@ -554,9 +562,10 @@ namespace Renci.SshNet
             ThrowHelper.ThrowIfNull(socketFactory);
             ThrowHelper.ThrowIfNull(socketFactory);
 
 
             ConnectionInfo = connectionInfo;
             ConnectionInfo = connectionInfo;
+            SessionLoggerFactory = connectionInfo.LoggerFactory ?? SshNetLoggingConfiguration.LoggerFactory;
             _serviceFactory = serviceFactory;
             _serviceFactory = serviceFactory;
             _socketFactory = socketFactory;
             _socketFactory = socketFactory;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<Session>();
+            _logger = SessionLoggerFactory.CreateLogger<Session>();
             _messageListenerCompleted = new ManualResetEvent(initialState: true);
             _messageListenerCompleted = new ManualResetEvent(initialState: true);
         }
         }
 
 

+ 1 - 1
src/Renci.SshNet/Sftp/SftpFileReader.cs

@@ -71,7 +71,7 @@ namespace Renci.SshNet.Sftp
             _readAheadCompleted = new ManualResetEvent(initialState: false);
             _readAheadCompleted = new ManualResetEvent(initialState: false);
             _disposingWaitHandle = new ManualResetEvent(initialState: false);
             _disposingWaitHandle = new ManualResetEvent(initialState: false);
             _waitHandles = _sftpSession.CreateWaitHandleArray(_disposingWaitHandle, _semaphore.AvailableWaitHandle);
             _waitHandles = _sftpSession.CreateWaitHandleArray(_disposingWaitHandle, _semaphore.AvailableWaitHandle);
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger<SftpFileReader>();
+            _logger = sftpSession.SessionLoggerFactory.CreateLogger<SftpFileReader>();
 
 
             StartReadAhead();
             StartReadAhead();
         }
         }

+ 10 - 9
src/Renci.SshNet/SubsystemSession.cs

@@ -24,7 +24,7 @@ namespace Renci.SshNet
 
 
         private readonly string _subsystemName;
         private readonly string _subsystemName;
         private readonly ILogger _logger;
         private readonly ILogger _logger;
-        private ISession _session;
+        private readonly ISession _session;
         private IChannelSession _channel;
         private IChannelSession _channel;
         private Exception _exception;
         private Exception _exception;
         private EventWaitHandle _errorOccurredWaitHandle = new ManualResetEvent(initialState: false);
         private EventWaitHandle _errorOccurredWaitHandle = new ManualResetEvent(initialState: false);
@@ -72,6 +72,14 @@ namespace Renci.SshNet
             get { return _channel is not null && _channel.IsOpen; }
             get { return _channel is not null && _channel.IsOpen; }
         }
         }
 
 
+        public ILoggerFactory SessionLoggerFactory
+        {
+            get
+            {
+                return _session.SessionLoggerFactory;
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="SubsystemSession"/> class.
         /// Initializes a new instance of the <see cref="SubsystemSession"/> class.
         /// </summary>
         /// </summary>
@@ -86,7 +94,7 @@ namespace Renci.SshNet
 
 
             _session = session;
             _session = session;
             _subsystemName = subsystemName;
             _subsystemName = subsystemName;
-            _logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
+            _logger = SessionLoggerFactory.CreateLogger(GetType());
             OperationTimeout = operationTimeout;
             OperationTimeout = operationTimeout;
         }
         }
 
 
@@ -522,11 +530,6 @@ namespace Renci.SshNet
         /// </remarks>
         /// </remarks>
         private void UnsubscribeFromSessionEvents(ISession session)
         private void UnsubscribeFromSessionEvents(ISession session)
         {
         {
-            if (session is null)
-            {
-                return;
-            }
-
             session.Disconnected -= Session_Disconnected;
             session.Disconnected -= Session_Disconnected;
             session.ErrorOccured -= Session_ErrorOccurred;
             session.ErrorOccured -= Session_ErrorOccurred;
         }
         }
@@ -555,8 +558,6 @@ namespace Renci.SshNet
             {
             {
                 Disconnect();
                 Disconnect();
 
 
-                _session = null;
-
                 var errorOccurredWaitHandle = _errorOccurredWaitHandle;
                 var errorOccurredWaitHandle = _errorOccurredWaitHandle;
                 if (errorOccurredWaitHandle != null)
                 if (errorOccurredWaitHandle != null)
                 {
                 {

+ 4 - 1
test/Renci.SshNet.Tests/Classes/BaseClientTestBase.cs

@@ -1,4 +1,6 @@
-using Moq;
+using Microsoft.Extensions.Logging.Abstractions;
+
+using Moq;
 
 
 using Renci.SshNet.Connection;
 using Renci.SshNet.Connection;
 using Renci.SshNet.Tests.Common;
 using Renci.SshNet.Tests.Common;
@@ -16,6 +18,7 @@ namespace Renci.SshNet.Tests.Classes
             ServiceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
             ServiceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
             SocketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
             SocketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
+            SessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
         }
         }
 
 
         protected virtual void SetupData()
         protected virtual void SetupData()

+ 2 - 0
test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs

@@ -2,6 +2,7 @@
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -23,6 +24,7 @@ namespace Renci.SshNet.Tests.Classes
         public void Init()
         public void Init()
         {
         {
             var sessionMock = new Mock<ISession>();
             var sessionMock = new Mock<ISession>();
+            sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             var serviceFactoryMock = new Mock<IServiceFactory>();
             var serviceFactoryMock = new Mock<IServiceFactory>();
             var socketFactoryMock = new Mock<ISocketFactory>();
             var socketFactoryMock = new Mock<ISocketFactory>();
 
 

+ 3 - 1
test/Renci.SshNet.Tests/Classes/BaseClientTest_Disconnected_Connect.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
 
 
@@ -25,6 +26,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _socketFactory2Mock = new Mock<ISocketFactory>(MockBehavior.Strict);
             _socketFactory2Mock = new Mock<ISocketFactory>(MockBehavior.Strict);
             _session2Mock = new Mock<ISession>(MockBehavior.Strict);
             _session2Mock = new Mock<ISession>(MockBehavior.Strict);
+            _session2Mock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
         }
         }
 
 
         protected override void SetupMocks()
         protected override void SetupMocks()

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -49,6 +50,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _channelCloseTimeout = TimeSpan.FromSeconds(random.Next(10, 20));
             _channelCloseTimeout = TimeSpan.FromSeconds(random.Next(10, 20));
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
             _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -78,6 +79,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _remotePacketSize = (uint)random.Next(100, 200);
             _remotePacketSize = (uint)random.Next(100, 200);
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
             _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -83,6 +84,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _remoteEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
             _remoteEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
             _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
 
 

+ 3 - 1
test/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTestBase.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
 
 
@@ -21,6 +22,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
         protected void CreateMocks()
         protected void CreateMocks()
         {
         {
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
+            SessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             ConnectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             ConnectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
         }
         }
 
 

+ 3 - 1
test/Renci.SshNet.Tests/Classes/Channels/ChannelTestBase.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
 
 
@@ -21,6 +22,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
         protected void CreateMocks()
         protected void CreateMocks()
         {
         {
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
+            SessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             ConnectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             ConnectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenConfirmationReceived_OnOpenConfirmation_Exception.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -40,6 +41,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _channelExceptionRegister = new List<ExceptionEventArgs>();
             _channelExceptionRegister = new List<ExceptionEventArgs>();
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenFailureReceived_OnOpenFailure_Exception.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -38,6 +39,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _channelExceptionRegister = new List<ExceptionEventArgs>();
             _channelExceptionRegister = new List<ExceptionEventArgs>();
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);

+ 3 - 1
test/Renci.SshNet.Tests/Classes/ClientAuthenticationTestBase.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
 
 
@@ -22,6 +23,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             ConnectionInfoMock = new Mock<IConnectionInfoInternal>(MockBehavior.Strict);
             ConnectionInfoMock = new Mock<IConnectionInfoInternal>(MockBehavior.Strict);
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
             SessionMock = new Mock<ISession>(MockBehavior.Strict);
+            SessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             NoneAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
             NoneAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
             PasswordAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
             PasswordAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
             PublicKeyAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
             PublicKeyAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);

+ 4 - 2
test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTestBase.cs

@@ -1,4 +1,6 @@
-using Moq;
+using Microsoft.Extensions.Logging.Abstractions;
+
+using Moq;
 
 
 using Renci.SshNet.Connection;
 using Renci.SshNet.Connection;
 using Renci.SshNet.Tests.Common;
 using Renci.SshNet.Tests.Common;
@@ -18,7 +20,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
 
 
         protected virtual void SetupData()
         protected virtual void SetupData()
         {
         {
-            Connector = new DirectConnector(SocketFactoryMock.Object);
+            Connector = new DirectConnector(SocketFactoryMock.Object, NullLoggerFactory.Instance);
             SocketFactory = new SocketFactory();
             SocketFactory = new SocketFactory();
         }
         }
 
 

+ 4 - 2
test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTestBase.cs

@@ -1,4 +1,6 @@
-using Moq;
+using Microsoft.Extensions.Logging.Abstractions;
+
+using Moq;
 
 
 using Renci.SshNet.Connection;
 using Renci.SshNet.Connection;
 using Renci.SshNet.Tests.Common;
 using Renci.SshNet.Tests.Common;
@@ -18,7 +20,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
 
 
         protected virtual void SetupData()
         protected virtual void SetupData()
         {
         {
-            Connector = new HttpConnector(SocketFactoryMock.Object);
+            Connector = new HttpConnector(SocketFactoryMock.Object, NullLoggerFactory.Instance);
             SocketFactory = new SocketFactory();
             SocketFactory = new SocketFactory();
         }
         }
 
 

+ 3 - 1
test/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTestBase.cs

@@ -1,5 +1,7 @@
 using System.Net;
 using System.Net;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
+
 using Moq;
 using Moq;
 
 
 using Renci.SshNet.Connection;
 using Renci.SshNet.Connection;
@@ -20,7 +22,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
 
 
         protected virtual void SetupData()
         protected virtual void SetupData()
         {
         {
-            Connector = new Socks4Connector(SocketFactoryMock.Object);
+            Connector = new Socks4Connector(SocketFactoryMock.Object, NullLoggerFactory.Instance);
             SocketFactory = new SocketFactory();
             SocketFactory = new SocketFactory();
         }
         }
 
 

+ 3 - 1
test/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTestBase.cs

@@ -2,6 +2,8 @@
 using System.Net;
 using System.Net;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
+
 using Moq;
 using Moq;
 
 
 using Renci.SshNet.Connection;
 using Renci.SshNet.Connection;
@@ -22,7 +24,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
 
 
         protected virtual void SetupData()
         protected virtual void SetupData()
         {
         {
-            Connector = new Socks5Connector(SocketFactoryMock.Object);
+            Connector = new Socks5Connector(SocketFactoryMock.Object, NullLoggerFactory.Instance);
             SocketFactory = new SocketFactory();
             SocketFactory = new SocketFactory();
         }
         }
 
 

+ 3 - 1
test/Renci.SshNet.Tests/Classes/ConnectionInfoTest_Authenticate_Failure.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
 
 
@@ -29,6 +30,7 @@ namespace Renci.SshNet.Tests.Classes
             _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
             _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
             _clientAuthenticationMock = new Mock<IClientAuthentication>(MockBehavior.Strict);
             _clientAuthenticationMock = new Mock<IClientAuthentication>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfo = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None,
             _connectionInfo = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None,
                 Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
                 Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,

+ 3 - 1
test/Renci.SshNet.Tests/Classes/ConnectionInfoTest_Authenticate_Success.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
 
 
@@ -26,6 +27,7 @@ namespace Renci.SshNet.Tests.Classes
             _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
             _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
             _clientAuthenticationMock = new Mock<IClientAuthentication>(MockBehavior.Strict);
             _clientAuthenticationMock = new Mock<IClientAuthentication>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfo = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None,
             _connectionInfo = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None,
                 Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
                 Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortNeverStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -46,6 +47,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelBound.cs

@@ -7,6 +7,7 @@ using System.Net.Sockets;
 using System.Text;
 using System.Text;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -71,6 +72,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs

@@ -5,6 +5,7 @@ using System.Net.Sockets;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -57,6 +58,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStopped.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -46,6 +47,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_SessionErrorOccurred_ChannelBound.cs

@@ -7,6 +7,7 @@ using System.Net.Sockets;
 using System.Text;
 using System.Text;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -72,6 +73,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortNeverStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -48,6 +49,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -49,6 +50,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStopped.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -48,6 +49,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_SessionNotConnected.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -47,6 +48,7 @@ namespace Renci.SshNet.Tests.Classes
             _endpoint = new IPEndPoint(IPAddress.Loopback, 8122);
             _endpoint = new IPEndPoint(IPAddress.Loopback, 8122);
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
 
 
             _sessionMock.Setup(p => p.IsConnected).Returns(false);
             _sessionMock.Setup(p => p.IsConnected).Returns(false);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketSendShutdownImmediately.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -84,6 +85,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketVersionNotSupported.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -68,6 +69,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs

@@ -7,6 +7,7 @@ using System.Net.Sockets;
 using System.Text;
 using System.Text;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -70,6 +71,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs

@@ -5,6 +5,7 @@ using System.Net.Sockets;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -57,6 +58,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _ = _connectionInfoMock.Setup(p => p.Timeout)
             _ = _connectionInfoMock.Setup(p => p.Timeout)

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStopped.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -46,6 +47,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Net;
 using System.Net;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -42,6 +43,7 @@ namespace Renci.SshNet.Tests.Classes
             _exceptionRegister = new List<ExceptionEventArgs>();
             _exceptionRegister = new List<ExceptionEventArgs>();
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
 
 
             var sequence = new MockSequence();
             var sequence = new MockSequence();

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortNeverStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -51,6 +52,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelBound.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -75,6 +76,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelNotBound.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStopped.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -51,6 +52,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortNeverStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _ = _connectionInfoMock.Setup(p => p.Timeout)
             _ = _connectionInfoMock.Setup(p => p.Timeout)

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _ = _connectionInfoMock.Setup(p => p.Timeout)
             _ = _connectionInfoMock.Setup(p => p.Timeout)

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStopped.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _ = _connectionInfoMock.Setup(p => p.Timeout)
             _ = _connectionInfoMock.Setup(p => p.Timeout)

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_SessionNotConnected.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
                 random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
                 random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
 
 
             _sessionMock.Setup(p => p.IsConnected).Returns(false);
             _sessionMock.Setup(p => p.IsConnected).Returns(false);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_SessionNull.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -51,6 +52,7 @@ namespace Renci.SshNet.Tests.Classes
                 random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
                 random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
 
 
             _sessionMock.Setup(p => p.IsConnected).Returns(false);
             _sessionMock.Setup(p => p.IsConnected).Returns(false);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortNeverStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -51,6 +52,7 @@ namespace Renci.SshNet.Tests.Classes
                 random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
                 random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
 
 
             _forwardedPort = new ForwardedPortLocal(_localEndpoint.Address.ToString(), (uint)_localEndpoint.Port,
             _forwardedPort = new ForwardedPortLocal(_localEndpoint.Address.ToString(), (uint)_localEndpoint.Port,

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelBound.cs

@@ -4,6 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -65,6 +66,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelNotBound.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelDirectTcpip>(MockBehavior.Strict);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -50,6 +51,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortNeverStarted.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
 using System.Net;
 using System.Net;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -52,6 +53,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStarted_ChannelBound.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -71,6 +72,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelMock = new Mock<IChannelForwardedTcpip>(MockBehavior.Strict);
             _channelMock = new Mock<IChannelForwardedTcpip>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStopped.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -54,6 +55,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortNeverStarted.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -61,6 +62,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortStarted.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -62,6 +63,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortStopped.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -61,6 +62,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_SessionNotConnected.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
 using System.Net;
 using System.Net;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -56,6 +57,7 @@ namespace Renci.SshNet.Tests.Classes
             _remoteEndpoint = new IPEndPoint(IPAddress.Parse("193.168.1.5"), random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
             _remoteEndpoint = new IPEndPoint(IPAddress.Parse("193.168.1.5"), random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort));
 
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
 
 
             _ = _sessionMock.Setup(p => p.IsConnected)
             _ = _sessionMock.Setup(p => p.IsConnected)

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Started.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -59,6 +60,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortNeverStarted.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -61,6 +62,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(15));
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateConnector.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -20,6 +21,7 @@ namespace Renci.SshNet.Tests.Classes
         {
         {
             _serviceFactory = new ServiceFactory();
             _serviceFactory = new ServiceFactory();
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+            _connectionInfoMock.Setup(p => p.LoggerFactory).Returns(NullLoggerFactory.Instance);
             _socketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
             _socketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateSftpFileReader_EndLStatThrowsSshException.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -39,6 +40,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
             _sftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
+            _sftpSessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _sftpFileReaderMock = new Mock<ISftpFileReader>(MockBehavior.Strict);
             _sftpFileReaderMock = new Mock<ISftpFileReader>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -44,6 +45,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestReturnsFalse.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -41,6 +42,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestThrowsException.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -44,6 +45,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendShellRequestReturnsFalse.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -41,6 +42,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendShellRequestThrowsException.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -43,6 +44,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_Success.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -40,6 +41,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs

@@ -6,6 +6,7 @@ using System.Net.Sockets;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -173,7 +174,7 @@ namespace Renci.SshNet.Tests.Classes
                 };
                 };
             ServerListener.Start();
             ServerListener.Start();
 
 
-            ClientSocket = new DirectConnector(_socketFactory).Connect(ConnectionInfo);
+            ClientSocket = new DirectConnector(_socketFactory, NullLoggerFactory.Instance).Connect(ConnectionInfo);
 
 
             void SendKeyExchangeInit()
             void SendKeyExchangeInit()
             {
             {

+ 2 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerAndClientDisconnectRace.cs

@@ -5,6 +5,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -132,7 +133,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             ServerListener.Start();
             ServerListener.Start();
 
 
-            ClientSocket = new DirectConnector(_socketFactory).Connect(ConnectionInfo);
+            ClientSocket = new DirectConnector(_socketFactory, NullLoggerFactory.Instance).Connect(ConnectionInfo);
         }
         }
 
 
         private void CreateMocks()
         private void CreateMocks()

+ 2 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_ConnectingBase.cs

@@ -5,6 +5,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -199,7 +200,7 @@ namespace Renci.SshNet.Tests.Classes
             };
             };
             ServerListener.Start();
             ServerListener.Start();
 
 
-            ClientSocket = new DirectConnector(_socketFactory).Connect(ConnectionInfo);
+            ClientSocket = new DirectConnector(_socketFactory, NullLoggerFactory.Instance).Connect(ConnectionInfo);
         }
         }
 
 
         private void CreateMocks()
         private void CreateMocks()

+ 2 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_SocketConnected_BadPacketAndDispose.cs

@@ -2,6 +2,7 @@
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -78,7 +79,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _session = new Session(_connectionInfo, _serviceFactoryMock.Object, _socketFactoryMock.Object);
             _session = new Session(_connectionInfo, _serviceFactoryMock.Object, _socketFactoryMock.Object);
 
 
-            _clientSocket = new DirectConnector(_socketFactory).Connect(_connectionInfo);
+            _clientSocket = new DirectConnector(_socketFactory, NullLoggerFactory.Instance).Connect(_connectionInfo);
         }
         }
 
 
         protected void SetupMocks()
         protected void SetupMocks()

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Sftp/SftpFileReaderTestBase.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -19,6 +20,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
         protected void CreateMocks()
         protected void CreateMocks()
         {
         {
             SftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
             SftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
+            SftpSessionMock.Setup(s => s.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
         }
         }
 
 
         protected abstract void SetupMocks();
         protected abstract void SetupMocks();

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_Connected_RequestRead.cs

@@ -2,6 +2,7 @@
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -98,6 +99,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_Connected_RequestStatVfs.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -91,6 +92,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }
 
 

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_DataReceived_MultipleSftpMessagesInSingleSshDataMessage.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -113,6 +114,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _sftpResponseFactoryMock = new Mock<ISftpResponseFactory>(MockBehavior.Strict);
             _sftpResponseFactoryMock = new Mock<ISftpResponseFactory>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_DataReceived_MultipleSftpMessagesSplitOverMultipleSshDataMessages.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -113,6 +114,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _sftpResponseFactoryMock = new Mock<ISftpResponseFactory>(MockBehavior.Strict);
             _sftpResponseFactoryMock = new Mock<ISftpResponseFactory>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/Sftp/SftpSessionTest_DataReceived_SingleSftpMessageInSshDataMessage.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -96,6 +97,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _sftpResponseFactoryMock = new Mock<ISftpResponseFactory>(MockBehavior.Strict);
             _sftpResponseFactoryMock = new Mock<ISftpResponseFactory>(MockBehavior.Strict);
         }
         }

+ 4 - 0
test/Renci.SshNet.Tests/Classes/SftpClientTest.UploadFile.cs

@@ -4,6 +4,8 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -173,6 +175,8 @@ namespace Renci.SshNet.Tests.Classes
 
 
             public WaitHandle MessageListenerCompleted => throw new NotImplementedException();
             public WaitHandle MessageListenerCompleted => throw new NotImplementedException();
 
 
+            public ILoggerFactory SessionLoggerFactory => NullLoggerFactory.Instance;
+
             public void Connect()
             public void Connect()
             {
             {
             }
             }

+ 4 - 0
test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs

@@ -4,6 +4,8 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -216,6 +218,8 @@ namespace Renci.SshNet.Tests.Classes
 
 
             public WaitHandle MessageListenerCompleted => throw new NotImplementedException();
             public WaitHandle MessageListenerCompleted => throw new NotImplementedException();
 
 
+            public ILoggerFactory SessionLoggerFactory => NullLoggerFactory.Instance;
+
             public void Connect()
             public void Connect()
             {
             {
             }
             }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs

@@ -4,6 +4,7 @@ using System.Globalization;
 using System.Text;
 using System.Text;
 using System.Threading;
 using System.Threading;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -47,6 +48,7 @@ namespace Renci.SshNet.Tests.Classes
 
 
             _encoding = Encoding.UTF8;
             _encoding = Encoding.UTF8;
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs

@@ -5,6 +5,7 @@ using System.Text;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -32,6 +33,7 @@ namespace Renci.SshNet.Tests.Classes
             connectionInfoMock.Setup(p => p.Encoding).Returns(Encoding.UTF8);
             connectionInfoMock.Setup(p => p.Encoding).Returns(Encoding.UTF8);
 
 
             var sessionMock = new Mock<ISession>();
             var sessionMock = new Mock<ISession>();
+            sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
 
 
             sessionMock.Setup(p => p.ConnectionInfo).Returns(connectionInfoMock.Object);
             sessionMock.Setup(p => p.ConnectionInfo).Returns(connectionInfoMock.Object);
             sessionMock.Setup(p => p.CreateChannelSession()).Returns(_channelSessionStub);
             sessionMock.Setup(p => p.CreateChannelSession()).Returns(_channelSessionStub);

+ 2 - 0
test/Renci.SshNet.Tests/Classes/ShellStreamTest_Write_WriteBufferEmptyAndWriteMoreBytesThanBufferSize.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using Microsoft.Extensions.Logging.Abstractions;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 
 using Moq;
 using Moq;
@@ -65,6 +66,7 @@ namespace Renci.SshNet.Tests.Classes
         private void CreateMocks()
         private void CreateMocks()
         {
         {
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _sessionMock.Setup(p => p.SessionLoggerFactory).Returns(NullLoggerFactory.Instance);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
             _channelSessionMock = new Mock<IChannelSession>(MockBehavior.Strict);
         }
         }

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