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 in Visual Basic.
To determine the listeners for My.Application.Log
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.
Not every assembly has a configuration file.
The configuration file is an XML file.
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:
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.
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.
Locate the <add> elements in the <listeners> section.
These elements add the named log listeners to My.Application.Log source.
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.
For many types of shared listeners, the listener's initialization data includes a description of where the listener directs the data:
A FileLogTraceListener listener writes to a file log, as described in the introduction.
A EventLogTraceListener listener writes information to the computer event log specified by the initializeData parameter. To view an event log, you can use Server Explorer or Windows Event Viewer. For more information, see ETW Events in the .NET Framework.
A ConsoleTraceListener listener writes to the command-line console.
For information about where other types of log listeners write information, consult that type's documentation.