Share via


Using the Application Settings File

The application settings file contains various application data used by this example. Application settings provide a place to store and retrieve property settings and other information for the application at run time. These settings specify what type of events to listen to, whether to use a database or an XML file to store the events received, which database to use, what the batch size should be for saving the events, and so on. The following table lists the name, type, description, and value of each setting.

Example

Description

The following table lists the name, type, description, and value of each setting.

Name of setting Type Description Value

BatchSize

Integer

An integer that specifies how many event entries must be written at a time to the database. This controls the frequency of network data transfers to the database by collecting several records before they are sent over the network.

1000

DatabaseName

String

The name of the database used, or the file name when used in XML mode.

EventsDatabase

EventQuery

String

The query that specifies which events to listen for.

<QueryList><Query Id="0" >

<Select Path="Application">*</Select>

<Select Path="Security">*</Select></Query></QueryList>

LogPath

String

The Event Log path.

System

ReadExistingEvents

Boolean

A flag that determines whether to read existing events or only listen on new ones.

True

SqlConnectionString

String

The string that specifies how to connect to the SQL database. Use the appropriate value here for your configuration.

Insert SQL-Connection string to upload to SQL.

SqlTableDefinition

String

Defines the table structure to capture the event data. The formatting parser expects a “Table Name=XPath into EventXml” pairs separated by a comma. For more information about the Xpath see the EventXml schema documentation.

ProviderName=Event/System/Provider/@Name,

Channel=Event/System/Channel,

TimeCreated=Event/System/TimeCreated/@SystemTime,

RecordId=Event/System/EventRecordID,

EventId=Event/System/EventID

SubscribeForFutureEvents

Boolean

A flag to decide whether to keep running the example to capture future events or whether to exit the program.

True

XmlMode

Boolean

The flag that decides whether the event data is captured in an XML file or the specified database.

True

Code

The following is the content, in XML format, of the Settings file.

<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="https://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" 
GeneratedClassNamespace="EventLogSample" 
GeneratedClassName="Settings">
  <Profiles />
  <Settings>
    <Setting Name="SqlConnectionString" Type="System.String" Scope="Application">
    <!-- Insert SQL connection string to upload to XML --></Setting>
    <Setting Name="LogPath" Type="System.String" Scope="Application">
      <Value Profile="(Default)">System</Value>
    </Setting>
    <Setting Name="EventQuery" Type="System.String" Scope="Application">
      <Value Profile="(Default)">&lt;QueryList&gt;&lt;Query Id="0" &gt;
  &lt;Select Path="Application"&gt;*&lt;/Select&gt;
  &lt;Select Path="Security"&gt;*&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Value>
    </Setting>
    <Setting Name="SqlTableDefinition" Type="System.String" Scope="Application">
      <Value Profile="(Default)">ProviderName=Event/System/Provider/@Name,Channel=Event/System/Channel,TimeCreated=Event/System/TimeCreated/@SystemTime,RecordId=Event/System/EventRecordID,EventId=Event/System/EventID</Value>
    </Setting>
    <Setting Name="DatabaseName" Type="System.String" Scope="Application">
      <Value Profile="(Default)">EventsDatabase</Value>
    </Setting>
    <Setting Name="ReadExistingEvents" Type="System.Boolean" Scope="Application">
      <Value Profile="(Default)">True</Value>
    </Setting>
    <Setting Name="SubscribeForFutureEvents" Type="System.Boolean" Scope="Application">
      <Value Profile="(Default)">True</Value>
    </Setting>
    <Setting Name="XmlMode" Type="System.Boolean" Scope="Application">
      <Value Profile="(Default)">True</Value>
    </Setting>
    <Setting Name="BatchSize" Type="System.Int64" Scope="Application">
      <Value Profile="(Default)">1000</Value>
    </Setting>
  </Settings>
</SettingsFile>

See Also

Concepts

How to: Listen for Events and Store Them in a SQL Database

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.