Redaguoti

Bendrinti naudojant


Walkthrough: Determining Where My.Application.Log Writes Information (Visual Basic)

The My.Application.Log object can write information to several log listeners. The log listeners are configured by the computer's configuration file and can be overridden by an application's configuration file. This topic describes the default settings and how to determine the settings for your application.

For more information about the default output locations, see Working with Application Logs.

To determine the listeners for My.Application.Log

  1. Locate the assembly's configuration file. If you are developing the assembly, you can access the app.config in Visual Studio from the Solution Explorer. Otherwise, the configuration file name is the assembly's name appended with ".config", and it is located in the same directory as the assembly.

    Note

    Not every assembly has a configuration file.

    The configuration file is an XML file.

  2. Locate the <listeners> section, in the <source> section with the name attribute "DefaultSource", located in the <sources> section. The <sources> section is located in the <system.diagnostics> section, in the top-level <configuration> section.

    If these sections do not exist, then the computer's configuration file may configure the My.Application.Log log listeners. The following steps describe how to determine what the computer configuration file defines:

    1. Locate the computer's machine.config file. Typically, it is located in the SystemRoot\Microsoft.NET\Framework\frameworkVersion\CONFIG directory, where SystemRoot is the operating system directory, and frameworkVersion is the version of the .NET Framework.

      The settings in machine.config can be overridden by an application's configuration file.

      If the optional elements listed below do not exist, you can create them.

    2. Locate the <listeners> section, in the <source> section with the name attribute "DefaultSource", in the <sources> section, in the <system.diagnostics> section, in the top-level <configuration> section.

      If these sections do not exist, then the My.Application.Log has only the default log listeners.

  3. Locate the <add> elements in the <listeners> section.

    These elements add the named log listeners to My.Application.Log source.

  4. Locate the <add> elements with the names of the log listeners in the <sharedListeners> section, in the <system.diagnostics> section, in the top-level <configuration> section.

  5. For many types of shared listeners, the listener's initialization data includes a description of where the listener directs the data:

See also