Skip to content

LogReceiverWebServiceTarget - Dispose IWcfLogReceiverClient instead of Close#37

Merged
snakefoot merged 1 commit into
NLog:masterfrom
snakefoot:master
Apr 3, 2026
Merged

LogReceiverWebServiceTarget - Dispose IWcfLogReceiverClient instead of Close#37
snakefoot merged 1 commit into
NLog:masterfrom
snakefoot:master

Conversation

@snakefoot
Copy link
Copy Markdown
Contributor

@snakefoot snakefoot commented Apr 3, 2026

Avoid leaking WCF-clients from dangling event-handlers with references to NLog LogReceiverWebServiceTarget.

Little surprised that by default then a new WCF-client is created for every LogEvent. Would have expected that it would be more optimal to reuse the WCF-client. It is possible to inherit from LogReceiverWebServiceTarget and change the behavior to reuse the same WCF-client, but one have to implement some funny logic to avoid constant re-subscription to ProcessLogMessagesCompleted-EventHandler.

  • But there is builtin a small optimization, so new LogEvents that arrives while waiting for first LogEvent to be sent, are queued and send in a single batch when first LogEvent send-completes.

Seems it is a good idea to explicit setup a NLog BufferingWrapper around LogReceiverWebServiceTarget with FlushTimeout of 200ms (or higher) to avoid constantly allocating new WCF-clients.

@snakefoot snakefoot merged commit 0838760 into NLog:master Apr 3, 2026
3 checks passed
@snakefoot snakefoot added the enhancement New feature or request label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant