Logging and tracing Using Microsoft Tracing API A

  • Slides: 6
Download presentation
Logging and tracing Using Microsoft Tracing API A very brief introduction Logging and tracing

Logging and tracing Using Microsoft Tracing API A very brief introduction Logging and tracing 1

Introduction • Ships must keep a written log telling speed, direction, destination, etc. •

Introduction • Ships must keep a written log telling speed, direction, destination, etc. • A kind of diary of the ship. • Large programs should keep a written log telling about all the major events in the “life” of the program. • Facebook produces 25 TB log file per day (2009)! • 25 TB = 25 000 0000 bytes • Server programs usually keeps a log telling which clients requested what service from the server – and when – and how the server responded to the request • Ordinary response • Exception(al) response Logging and tracing 2

Usages of logging • Monitoring a running system • Does it perform well, or

Usages of logging • Monitoring a running system • Does it perform well, or does it need more resources. • Debugging • Application does not work. Maybe the log can tell us why. • Comparable to the ”black box” on an airplane • Statistics • Example Web. Shop: • • • When do customers arrive? For how long do they shop? How large a percentage of customers actually buy something? Can the users find the intended way through the shop? Etc Logging and tracing 3

Microsoft Tracing framework • Name space: System. Diagnostics • Main class: Trace • Trace.

Microsoft Tracing framework • Name space: System. Diagnostics • Main class: Trace • Trace. Write. Line(“something happened in the life of the application”); • Example: Person. Trace • Trace. Auto. Flush = true; • Flush at every Write(…) and Write. Line(…) Logging and tracing 4

Trace listener • You can add several listeners to a Trace • Trace. Listeners.

Trace listener • You can add several listeners to a Trace • Trace. Listeners. Add(another listener) • Listeners can use different media: • Screen (aka. Console) • File, etc. • Listeners can use different formats • Ordinary text • XML • You can even make your own listener by extending the abstract class Trace. Listener • Example: Person. Trace -> My. Sms. Trace. Listener Logging and tracing 5

Design pattern: Observable • The Trace framework uses the Observable design pattern. • The

Design pattern: Observable • The Trace framework uses the Observable design pattern. • The various listeners are said to observe the Trace class (Observable) • The Observable class can have 0 -many Observers • Observers can be addede / removed at runtime • Everytime something happens to the Observable all the Observers are notified (a method is called) Logging and tracing 6