Castle Windsor: "LoggingFacility.UseNLog() is obsolete"
Asked Answered
L

1

5

Long ago, I made a little project wherein I hoped to learn about Castle Windsor. I put it aside (before really learning all that much) for quite some time. I just opened it up again now, and updated NuGet packages, and started getting a warning CS0618:

'LoggingFacility.UseNLog()' is obsolete: 'A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.'

I've googled based on this, but it's still not clear to me what I am supposed to do in order to replace the now-obsolete call, which is:

container.AddFacility<LoggingFacility>(f => f.UseNLog());

Any help would be appreciated. Thanks!

Lammastide answered 18/12, 2017 at 21:16 Comment(2)
Have you seen this? gist.github.com/dlidstrom/786131 container.AddFacility<LoggingFacility>(f => .LogUsing(LoggerImplementation.NLog).WithConfig("nlog.config"));Religion
Thowk, thanks, but yes, I did. It just doubles the warnings - when I replace my call with that, it says that both LoggingFacility.LogUsing(LoggerImplementation) AND LoggerImplementation are obsolete.Lammastide
L
10

Oooh, I think I have stumbled upon the answer. Haven't tested it yet, but the very least, the following does not give any compiler warning:

container.AddFacility<LoggingFacility>(f => f.LogUsing<NLogFactory>());
Lammastide answered 18/12, 2017 at 21:34 Comment(1)
That indeed is the way to go, as pointed out in the documentation github.com/castleproject/Windsor/blob/master/docs/…Reinaldoreinaldos

© 2022 - 2024 — McMap. All rights reserved.