@@ -68,11 +68,16 @@ public sealed class SeqTarget : Target
6868 /// A Seq <i>API key</i> that authenticates the client to the Seq server.
6969 /// </summary>
7070 public string ApiKey { get => ( _apiKey as SimpleLayout ) ? . Text ; set => _apiKey = value ?? string . Empty ; }
71-
71+
7272 /// <summary>
7373 /// The address of the proxy to use, including port separated by a colon. If not provided, default operating system proxy will be used.
7474 /// </summary>
75+
7576 public string ProxyAddress { get => ( _proxyAddress as SimpleLayout ) ? . Text ; set => _proxyAddress = value ?? string . Empty ; }
77+ /// <summary>
78+ /// Use default credentials
79+ /// </summary>
80+ public bool UseDefaultCredentials { get ; set ; }
7681
7782 /// <summary>
7883 /// A list of properties that will be attached to the events.
@@ -91,7 +96,7 @@ public int MaxRecursionLimit
9196 get => TemplatedClefLayout . MaxRecursionLimit ;
9297 set { TemplatedClefLayout . MaxRecursionLimit = value ; TextClefLayout . MaxRecursionLimit = value ; }
9398 }
94-
99+
95100 /// <summary>
96101 /// Construct a <see cref="SeqTarget"/>.
97102 /// </summary>
@@ -102,7 +107,7 @@ public SeqTarget()
102107 OptimizeBufferReuse = true ;
103108 JsonPayloadMaxLength = 128 * 1024 ;
104109 }
105-
110+
106111 /// <summary>
107112 /// Initializes the target. Can be used by inheriting classes
108113 /// to initialize logging.
@@ -130,8 +135,19 @@ protected override void InitializeTarget()
130135
131136 var proxyAddress = _proxyAddress ? . Render ( LogEventInfo . CreateNullEvent ( ) ) ?? string . Empty ;
132137 if ( ! string . IsNullOrEmpty ( proxyAddress ) )
133- handler = new HttpClientHandler { Proxy = new WebProxy ( new Uri ( proxyAddress ) , true ) } ;
134-
138+ handler = new HttpClientHandler { Proxy = new WebProxy ( new Uri ( proxyAddress ) , true ) } ;
139+ if ( UseDefaultCredentials )
140+ {
141+ if ( handler != null )
142+ {
143+ handler . UseDefaultCredentials = UseDefaultCredentials ;
144+ }
145+ else
146+ {
147+ handler = new HttpClientHandler { UseDefaultCredentials = UseDefaultCredentials } ;
148+ }
149+ }
150+
135151 _httpClient = handler == null ? new HttpClient ( ) : new HttpClient ( handler ) ;
136152 }
137153
@@ -187,7 +203,7 @@ async Task PostBatch(IList<AsyncLogEventInfo> logEvents)
187203 var request = new HttpRequestMessage ( HttpMethod . Post , _webRequestUri ) ;
188204 if ( ! string . IsNullOrWhiteSpace ( _headerApiKey ) )
189205 request . Headers . Add ( SeqApi . ApiKeyHeaderName , _headerApiKey ) ;
190-
206+
191207 List < AsyncLogEventInfo > extraBatch = null ;
192208 var totalPayload = 0 ;
193209 var payload = new StringBuilder ( ) ;
@@ -222,7 +238,7 @@ async Task PostBatch(IList<AsyncLogEventInfo> logEvents)
222238 }
223239
224240 request . Content = new StringContent ( payload . ToString ( ) , Utf8 , SeqApi . CompactLogEventFormatMediaType ) ;
225-
241+
226242 // Even if no events are above `_minimumLevel`, we'll send a batch to make sure we observe minimum
227243 // level changes sent by the server.
228244
0 commit comments