Now that Silverlight 2 has finally shipped. I'm wondering if anyone has put together any logging frameworks for it, maybe something like enterprise library logging or log4net? I'm interesting in something that can perform tracing client side and also log messages to the server.
So far the only project I have found is Clog on CodeProject. Has anyone used this? What were your thoughts on it?
if you just want to output debug messages to the console. You could use the Browser's console.log mechanism. I coded a extension method for that. You can find on my blog.
If you're willing to take your astronaut's helmet off for a minute, below is a lightweight logger I've written for Silverlight, for client-side logging (for use mainly with WCF operations but could be for any errors).
It was originally used in Monotouch for iPhone apps, and has been adapted for
IsolateStorage
. You can use theRead
method to display in a textbox if needed. Tested in SL4.I am about to delve into something similar myself for a product we've written. I'm considering using PostSharp for Silverlight to add client-side logging as an aspect.
I have used the NLog project with great success before under the full .NET Framework and the Compact Framework so I'll most likely take the existing framework code and add some logging targets:
I've briefly looked at Clog and it seems to suffer from one major flaw - it can't log a connection failure. So assuming your Web server is online all the time, yes it will work, but when problems occur upstream or on the server itself, the logging data is all lost and might even crash your application.
I'm using a JavaScript windows and making it scriptable in Silverlight. For "production", I can turn this window off but still save the log lines into memory, then if something goes wrong, send that off to the server. That way I get the best of both worlds - Simple, real-time logging on the client for debugging and logs for remote post-mortem situations that users may encounter.
I have ended up writing a new logging framework from scratch that addresses this flaw. I created a local queue that will get the log/trace messages and then do the filter and send them to the server. The queue then will be backed by Isolated Storage so even if the client goes off line permanently for that session the messages will be sent when it is back online.
You can use this one too: http://silverlightlogging.codeplex.com/