log4net errors when running NServiceBus.Host.exe with /installinfrastructure
If I run NServiceBus.Host.exe /installinfrastructure when there is a class implementing IConfigureThisEndpoint, then I get an error about acquiring a lock on the log file (as shown below).
If I delete the assembly containing my implementation of IConfigureThisEndpoint then re-run NServiceBus.Host.exe /installinfrastructure, then everything works as expected.
Error Details:
2012-06-05 21:55:14,749 [1] INFO NServiceBus.Licensing [(null)] <(null)> - Checking available license... log4net: FileAppender: Opening file for writing [C:\dev\MyProject\src\MyProject.Billing.Handlers\bin\Debug\Logs \log4net.log] append [True] log4net:ERROR [RollingFileAppender] Unable to acquire lock on file C:\dev\MyProject\src\MyProject.Billing.Handl ers\bin\Debug\Logs\log4net.log. The process cannot access the file 'C:\dev\MyProject\src\MyProject.Billing.Hand lers\bin\Debug\Logs\log4net.log' because it is being used by another process. log4net:ERROR [RollingFileAppender] OpenFile(C:\dev\MyProject\src\MyProject.Billing.Handlers\bin\Debug\Logs\log 4net.log,True) call failed. log4net.Appender.FileAppender+LockingStream+LockStateException: The file is not currently locked at log4net.Appender.FileAppender.LockingStream.AssertLocked() at log4net.Appender.FileAppender.LockingStream.get_CanWrite() at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding, Int32 bufferSize) at log4net.Appender.FileAppender.OpenFile(String fileName, Boolean append) at log4net.Appender.RollingFileAppender.OpenFile(String fileName, Boolean append) at log4net.Appender.FileAppender.SafeOpenFile(String fileName, Boolean append) log4net:ERROR [RollingFileAppender] No output stream or file set for the appender named [file].
What does your log4net appender look like?
I tried with:
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="log-file.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
And it didn't fail! Actually it failed with a different error #509, but this only occurs if RavenDB is not installed at all.
I am no longer able to reproduce this issue. It looks like the behaviour has changed when using the /installinfrastructure switch. It used to be that when you'd execute NServiceBus.Host.exe /installinfrastructure, it would install the infrastructure and then attempt to start the endpoint. Now it seems to just install the infrastructure and then quit (which is what I'd expect it to do).
Thanks for following up on this!