-
-
Notifications
You must be signed in to change notification settings - Fork 143
Logging
Antony Male edited this page Aug 7, 2014
·
10 revisions
Sometimes it's useful to see what Stylet's doing under the hood, particularly if it's not doing something you expect it to, or doing something unexpected.
Thankfully, Stylet can be easily configured to produce logging output, so you can get an insight into what it's doing.
To quickly enable logging, put the following in your Bootstrapper's Configure method:
protected override void Configure()
{
base.Configure();
Stylet.Logging.LogManager.IsEnabled = true;
}
This will print log messages to the Output window in Visual Studio. Internally, the default logger uses Trace.WriteLine
.
You can of course provide your own logger to Stylet, which Stylet will use to print log messages.
First, define a class which implements the Stylet.Logging.ILogger
interface:
public class MyLogger : Stylet.Logging.ILogger
{
public MyLogger(string loggerName)
{
// TODO
}
void Info(string format, params object[] args)
{
// TODO
}
void Warn(string format, params object[] args)
{
// TODO
}
void Error(Exception exception, string message = null)
{
// TODO
}
}
Then, configure the LogManager to use it. As before, in your Bootstrapper's Configure method:
protectedoverride void Configure()
{
base.Configure();
Stylet.Logging.LogManager.LoggerFactory = name => new MyLogger(name);
Stylet.Logging.LogManager.IsEnabled = true;
}
- Introduction
- Quick Start
- Bootstrapper
- ViewModel First
- Actions
- The WindowManager
- MessageBox
- The EventAggregator
- PropertyChangedBase
- Execute: Dispatching to the UI Thread
- Screens and Conductors
- BindableCollection
- Validation using ValidatingModelBase
- StyletIoC
- The ViewManager
- Listening to INotifyPropertyChanged
- Design Mode Support
- Logging
- Misc