This project has moved. For the latest updates, please go here.

How to replace the default LoggerFactory whicle hosting with OwinHost.exe

Sep 9, 2013 at 12:56 PM
Hi,

How can we replace the default LoggerFactory with a custom one while hosting with OwinHost.exe? I looked at the code and I can see the HostingEngine.EnableTracing method has the below code:

context.Builder.SetLoggerFactory(Microsoft.Owin.Logging.LoggerFactory.Default);

I looked at the setting file and thought it might support this configuration but I guess not. I also couldn't find anywhere to get in there. Should I just reset the app.Properties["server.LoggerFactory"] on the app Startup inside the Configuration method?

Thanks!
Coordinator
Sep 9, 2013 at 2:42 PM
Are you trying to replace where startup logs go? Or do you just want to replace the logger for middleware? If the latter then yes, just reset app.Properties["server.LoggerFactory"] in your config method.
Sep 10, 2013 at 7:06 AM
Thanks Chris!

I would love to able to replace this through the settings file that I pass to OwinHost.exe with the --settings switch. Is this possible for the future release?
Coordinator
Sep 10, 2013 at 3:41 PM
It's not already? That's a good idea.
Coordinator
Sep 10, 2013 at 4:20 PM
Sep 10, 2013 at 4:45 PM
Nice! thanks guys!
Coordinator
Dec 4, 2013 at 11:18 PM