# Write metrics to the trace log This sample demonstrates how to write [metrics](/monitoring/metrics/index.md) information to the trace log. There are many ways to look at the trace log. One way is to use the [DbgView utility provided by Sysinternals](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview). ![DbgView by Sysinternals](dbgview.png) ## Running the sample 1. Run the solution in the Visual Studio debugger. A console application will start. 1. Press the 'enter' key to send a message. 1. Check the Visual Studio debug output window for metrics information being written to the trace log. ## Sending metrics data to Trace Log ```cs var metrics = endpointConfiguration.EnableMetrics(); metrics.RegisterObservers( register: context => { foreach (var duration in context.Durations) { duration.Register( observer: (ref DurationEvent @event) => { Trace.WriteLine( $"Duration: '{duration.Name}'. Value: '{@event.Duration}' ({@event.MessageType})"); }); } foreach (var signal in context.Signals) { signal.Register( observer: (ref SignalEvent @event) => { Trace.WriteLine($"Signal: '{signal.Name}' ({@event.MessageType})"); }); } }); ```