Writing my entries to LoggingConsole

Mar 4, 2011 at 1:15 PM

I'm trying to figure out how I can use the client logging to log some events from my custom code. Let's say I have put the SMFPlayer on the page, and what should I do to log some custom messages on the LoggingConsole.

So far I found that Plugins could use the LogReady event, but I don't necessary want to write a cutom plugin (and deal with it activation) just to log something. Is there any easier way to do this?

Mar 4, 2011 at 3:35 PM

kobush, if you inherit SMFPlayer you can access the protected Logger property and call Logger.SendLogEntry method.

Tim Greenfield

Mar 4, 2011 at 3:38 PM

Ok. I will try that.

However this way I will have to pass reference to player all around. Is there any other way to access logger? By static singleton or injection perhaps?

Mar 8, 2011 at 9:03 AM

Hi Tim,

I tried to implement this the way you suggested but using Logger property won't work. This is because LoggingConsole is actually not registered as one of LogWriters. If you look at the SMFPlayer.OnLogEntryReceived event handler in addition to forwarding the entry to logger it will output it on the LoggingDisplayElement. So for short term solution I can use this protected method. However I think you should consider refactoring this such that LoggingConsole output is handled via it's own LogWriter.