Skip to content

Commit a94e704

Browse files
committed
Configure logging only once
1 parent 2c27c84 commit a94e704

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/Core.IntegrationTest/MailKitSmtpMailDeliveryServiceTests.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Security.Cryptography;
1+
using System.Security.Cryptography;
22
using System.Security.Cryptography.X509Certificates;
33
using Bit.Core.Models.Mail;
44
using Bit.Core.Platform.X509ChainCustomization;
@@ -16,6 +16,7 @@ namespace Bit.Core.IntegrationTest;
1616

1717
public class MailKitSmtpMailDeliveryServiceTests
1818
{
19+
private static int _loggingConfigured;
1920
private readonly X509Certificate2 _selfSignedCert;
2021

2122
public MailKitSmtpMailDeliveryServiceTests(ITestOutputHelper testOutputHelper)
@@ -34,6 +35,12 @@ private static X509Certificate2 CreateSelfSignedCert(string commonName)
3435

3536
private static void ConfigureSmtpServerLogging(ITestOutputHelper testOutputHelper)
3637
{
38+
// The logging in SmtpServer is configured statically so if we add it for each test it duplicates
39+
// but we cant add the logger statically either because we need ITestOutputHelper
40+
if (Interlocked.CompareExchange(ref _loggingConfigured, 1, 0) == 0)
41+
{
42+
return;
43+
}
3744
// Unfortunately this package doesn't public expose its logging infrastructure
3845
// so we use private reflection to try and access it.
3946
try

0 commit comments

Comments
 (0)