daspisch daspisch - 1 year ago 91
C# Question

Send event from NLog target using AppccelerateEventBroker

I want to put log messages to console and part of UI of my app simultaneously. But i cant find a way to do it with ninject.

I have a logger injected by ninject, and it perfectly make output to console and custom target. But I can't subscribe target to event broker because target initialization was outside ninject life-cycle.

Can anyone make some advice with this? How i can display logs in my UI?

Answer Source

Thanks to BatteryBackupUnit i found how to resolve this situation. First of all We need to inject logs target to kernel kernel.Bind<IMyTarget>().To<MyTarget>(); And then make a custom instantiation method NLog.Config.ConfigurationItemFactory.Default.CreateInstance = (type) => kernel.TryGet(type);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download