WireMock Standalone - null reference exception since settings.Logger #244

Closed
opened 2025-12-29 15:19:00 +01:00 by adam · 3 comments
Owner

Originally created by @larsbrekken on GitHub (Feb 1, 2020).

Two observations about the documentation at
https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock-as-a-standalone-process

  1. The page lists the argument --WireMockConsoleLogger, however the correct name is WireMockLogger. See https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Settings/WireMockServerSettingsParser.cs#L46-L49

  2. The page also says that the default logger is WireMockNullLogger, however if you try not to supply a logger you get a null reference exception since settings.Logger remains null and a line in StandAloneApp tries to use it:
    https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net.StandAlone/StandAloneApp.cs#L43

Originally created by @larsbrekken on GitHub (Feb 1, 2020). Two observations about the documentation at https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock-as-a-standalone-process 1. The page lists the argument `--WireMockConsoleLogger`, however the correct name is `WireMockLogger`. See https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Settings/WireMockServerSettingsParser.cs#L46-L49 2. The page also says that the default logger is `WireMockNullLogger`, however if you try not to supply a logger you get a null reference exception since `settings.Logger` remains null and a line in StandAloneApp tries to use it: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net.StandAlone/StandAloneApp.cs#L43
adam added the bug label 2025-12-29 15:19:00 +01:00
adam closed this issue 2025-12-29 15:19:01 +01:00
Author
Owner

@StefH commented on GitHub (Feb 2, 2020):

  1. OK: updated

  2. This is indeed a bug. If there is no logger, you cannot log.
    What would be solution?

  • only log that debug statement when a logger is present
  • else use console.writeline ?
@StefH commented on GitHub (Feb 2, 2020): 1. OK: updated 2. This is indeed a bug. If there is no logger, you cannot log. What would be solution? - only log that debug statement when a logger is present - else use console.writeline ?
Author
Owner

@larsbrekken commented on GitHub (Feb 2, 2020):

Thanks Stef.

For 2, if the default is WireMockNullLogger it seems ok not to log at all if the consumer has not specified a logger, at least that would be my expectation. So my vote would be to only log that statement when a logger is present.

@larsbrekken commented on GitHub (Feb 2, 2020): Thanks Stef. For 2, if the default is `WireMockNullLogger` it seems ok not to log at all if the consumer has not specified a logger, at least that would be my expectation. So my vote would be to only log that statement when a logger is present.
Author
Owner

@StefH commented on GitHub (Feb 5, 2020):

https://github.com/WireMock-Net/WireMock.Net/pull/414

@StefH commented on GitHub (Feb 5, 2020): https://github.com/WireMock-Net/WireMock.Net/pull/414
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#244