2010年11月19日 星期五

design pattern的應用範例 - log



requirements:
1. A consistent and simplified interface for logging information to any destination
2. Configuration settings determine When, Where, Format
3. extensible & flexible

example:
LogEntry logEntry = new LogEntry();
logEntry.EventId = 100;
logEntry.Priority = 2;
logEntry.Message = "Informational message";
logEntry.Categories.Add("Trace");
logEntry.Categories.Add("UI Events");
Logger.Write(logEntry);


Specs:
1. Enable control of what and how much information is logged
2. Enable logged information to be consumed b
y different monitoring/analysis applications with 3. little or no
customization
4. Provide useful and rich information in the logged data
5. Support for logging in distributed applications
6. Enable scenarios like metering and workflow tracing for web services