I am dealing with very complex objects in .NET (in my case a finite element model that can consist of thousands of other objects say a Model instance have a large list of Element instance). I would like to add log feature per Model and its only for showing the log to user, not storing it. A very simple way is to add a Status property of type string to model and write status into it. Also can create a more complex type Status but the thing i want to know what is prettier way to this? is there any built in feature in .NET for this purpose?
It works very similarly, except you create instances of TraceSource with different identifiers.
var source = new TraceSource("foo"); source.Listeners.Add(new ConsoleTraceListener()); source.TraceEvent(TraceEventType.Error, 1, "here be dragons");
The instances can be configured in code or through (app/web/machine).config files, though most of that is explained in the MSDN link.
As far as showing it to the user rather than storing it - that is just a matter of attaching the right listener. If a built-in listener type which does what you want does not exist, it is pretty easy to extend TraceListener. For example, in a small test utility, I created one that raised events when messages were written and then wired the events to display them in the system tray.