Udostępnij za pośrednictwem


Basics of .NET Framework Logs

There are many ways to log information from your Visual Basic applications, in addition to using the Visual Basic My.Application.Log and My.Log objects; many different .NET Framework classes are available. By logging information, you can monitor and measure your application's performance and diagnose errors.

Tracing, Debugging, and Instrumenting

The .NET Framework documentation uses several different terms that are related to logging: tracing, debugging, and instrumenting.

  • Tracing is a way for you to monitor the execution of your application while it is running. It is typically implemented using the Trace class. You can add tracing statements to your application when you develop it, and you can use that instrumentation both while you are developing the application and after you have deployed it.

  • Debugging is similar to tracing, but it is typically more verbose and it is turned off in release builds. It is typically implemented using the Trace class.

  • Instrumenting refers to adding code to your application that monitors or measures the level of a product's performance. Logging, tracing, and debugging are all forms of instrumentation. You can instrument your application by placing trace statements at strategic locations in your code. This is especially useful for distributed applications.

    With trace statements, you can instrument an application to display information not only when things go wrong but also to monitor how well the application is performing.

The Trace and Debug classes can, like the Visual Basic Log objects, record information about errors and application execution to logs, text files, or other devices for later analysis. In addition, they have methods that allow for finer control over the output. For more tracing classes, see Classes Used in .NET Framework Logging.

Logging and Tracing Basics

Once you instrument your application, you can:

The Trace and Debug classes provide the means to monitor and examine application performance either during development or after deployment. For example, you can use the Trace class to track particular types of actions in a deployed application as they occur (for example, creation of new database connections), letting you monitor the application's efficiency.

See Also

Concepts

Logging and Tracing in the .NET Framework with Visual Basic

Introduction to Instrumentation and Tracing

Classes Used in .NET Framework Logging

Reference

System.Diagnostics

Other Resources

Tracing and Instrumenting Applications