I am using Semantic Logging Application Block in our asp.net c# application. I am developing using Visual Studio 2013. I have created a listener which logs to a flat file and this works fine.
But I cannot get Console.LogToConsole to work. i.e., I don't see the log message in the Visual Studio Output window. I have checked the Immediate window and the log messages are not visible there either. Any suggestions are much appreciated.
Bit late to the party but you can create a custom event listener that writes to whatever you prefer (in this case Debug) like so:
internal class MyEventListener : EventListener
{
protected override void OnEventSourceCreated(EventSource eventSource)
{
base.OnEventSourceCreated(eventSource);
Debug.WriteLine("Listener attached to the source");
}
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
ICollection readOnlyCollectionObject = (ICollection)eventData.Payload;
object[] payload = new ArrayList(readOnlyCollectionObject).ToArray();
Debug.WriteLine(eventData.Message, payload);
}
}
And then, with our custom event listener built, we simply fire it up in the normal fashion:
var listener = new MyEventListener();
listener.EnableEvents(MyEventSource.Log, EventLevel.Informational);
MyEventSource.Log.MyEvent("Hello from the Immediate window!");
Credit to: http://www.shujaat.net/2013/08/slab-reactive-event-sourcing.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With