In the main mdcm project, the NLog class library for logging can be used without restrictions. There is a 2.0 beta version of NLog containing a Silverlight class library, which out of necessity is rather restricted.
However, with the help of the following response on Stackoverflow (many thanks, Stackoverflow user wageoghe) I have managed to add very simple logging capability to the Silverlight mdcm library as well.
With this solution, logging records are saved in a named file in the isolated storage of the running application. To enable logging globally, simply call the following static method:
Debug.InitializeIsolatedStorageDebugLogger();
To log something, simply access the Log member of the Debug static class:
Debug.Log.Warn("Some warning message {0}", variable);
This is a screen dump of the SL.DicomToXml Silverlight application included in the Silverlight mdcm project. To verify the logging functionality I have added a text box in the bottom of the application page to continuously display the contents of the NLog file:
No comments:
Post a Comment