You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
If I run the example for WireMock as a Windows Service, it throws the following exception on service startup:
Service cannot be started. System.IO.IOException: The handle is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.Console.set_OutputEncoding(Encoding value)
at WireMock.Logging.WireMockConsoleLogger..ctor() in /Logging/WireMockConsoleLogger.cs:line 18
at Wiremock.Net.Service.Program.Start() in C:\Development\WireMockStandalone\WireMock.Net.Service\Program.cs:line 60
at Wiremock.Net.Service.Program.Service.OnStart(String[] args) in C:\Development\WireMockStandalone\WireMock.Net.Service\Program.cs:line 24
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
Reason:
This is caused by the WireMockConsoleLogger which is also used if the application is actually running as a service. In this case the exception is thrown when the logger tries to access the console (which is actually not accessible in the service context).
Possible solution:
Use the WireMockConsoleLogger only in case the application is running as console app and use the WireMockNullLogger if it's running as service.
Of course, this can be easily fixed and does therefore not present a major problem, but it would be nice if the example would just work out of the box without the need to fix this.
The text was updated successfully, but these errors were encountered:
You're welcome. Thank you for maintaining this useful project!
For now I fixed it by using the WireMockNullLogger in the corresponding case.
I agree with you that using an actual logger would be better and make sense. I'll consider to implement it and submit a separate PR for it as well.
Where would you put the corresponding logger? Just in the WireMock.Net.Service-project like for example the WireMockLog4NetLogger which lives in the WireMock.Net.StandAlone.NETCoreApp-example?
I'd tend to use a log4net-logger and configure something like an EventLogAppender and maybe an additional file appender. Would this basically match your thoughts?
Correct. Just add a new WireMockEventLogger in the WireMock.Net.Service-project which can be based on log4net or just custom code to write to event log.
Problem:
If I run the example for WireMock as a Windows Service, it throws the following exception on service startup:
Reason:
This is caused by the
WireMockConsoleLogger
which is also used if the application is actually running as a service. In this case the exception is thrown when the logger tries to access the console (which is actually not accessible in the service context).Possible solution:
Use the
WireMockConsoleLogger
only in case the application is running as console app and use theWireMockNullLogger
if it's running as service.Of course, this can be easily fixed and does therefore not present a major problem, but it would be nice if the example would just work out of the box without the need to fix this.
The text was updated successfully, but these errors were encountered: