locked
How to specify a custom eventlog in app.config RRS feed

  • Question

  • Hello all,

    I'm trying to learn about .NET configuration files. I've setup my app.config file to log to the EventLog (apparently to the application log).

    I'd like to know how I can tell the configuration file to create my own custom event log instead of using the application log.

    Here is my configuration file.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
      </configSections>
      <connectionStrings>
        <add name="DBConnectionString" connectionString="TESTSTRING"
          providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.diagnostics>
        <sources>
          <!-- This section defines the logging configuration for My.Application.Log -->
          <source name="DefaultSource" switchName="DefaultSwitch">
            <listeners>
              <!-- Uncomment the below section to write to the Application Event Log -->
              <add name="EventLog"/>
            </listeners>
          </source>
        </sources>
        <switches>
          <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners> 
          <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
          <add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="OCRTest"/>
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    Thanks in advance to all replies.
    Friday, July 28, 2006 10:18 PM

All replies

  • Doing more research I've found a reference on goog that references My.Application.Log.EventLogName... however, I can't find it in the ms document or in inteliensese.
     
    Any ideas?
     
    Thanks in advance to all replies
    Tuesday, August 1, 2006 6:04 AM
  • What version of Visual Studio are you using?
    Tuesday, August 1, 2006 6:17 AM
    Moderator
  • I'm using Visual Studio 2005.
     
    Thanks for the reply.
    Wednesday, August 2, 2006 2:42 AM