System.ApplicationLog.GenericCSVLogReader

Applies To: Operations Manager 2007 R2

The System.ApplicationLog.GenericCSVLogReader data source module type is used to provide log entry data from a directory that contains delimited text-based generic log files. This module returns each generic log file entry data as System.ApplicationLog.GenericLogEntryData data.

Usage

Use the module to provide generic log entry data from within a workflow. If your log file does not include delimited text within each entry, use the System.ApplicationLog.GenericLogReader module type.

Type Definition

<DataSourceModuleType ID="System.ApplicationLog.GenericCSVLogReader" Accessibility="Public">
  <Configuration>
    <xsd:element name="LogFileDirectory" type="xsd:string" />
    <xsd:element name="LogFilePattern" type="xsd:string" />
    <xsd:element name="LogIsUTF8" type="xsd:string" />
    <xsd:element name="Separator" type="xsd:string" />
  </Configuration>
  <ModuleImplementation>
    <Composite>
      <MemberModules>
        <DataSource TypeID="System.ApplicationLog.GenericCSVLogReader.Internal" ID="DS">
          <LogFileType>7</LogFileType>
          <LogFileDirectory>$Config/LogFileDirectory$</LogFileDirectory>
          <LogFilePattern>$Config/LogFilePattern$</LogFilePattern>
          <LogIsUTF8>$Config/LogIsUTF8$</LogIsUTF8>
          <Separator>$Config/Separator$</Separator>
        </DataSource>
      </MemberModules>
      <Composition>
        <Node ID="DS" />
      </Composition>
    </Composite>
  </ModuleImplementation>
  <OutputType>System.ApplicationLog.GenericLogEntryData</OutputType>
</DataSourceModuleType>

Parameters

The System.ApplicationLog.GenericCSVLogReader module supports the configuration parameters described in the following table.

Parameter Type Overrideable Description

LogFileDirectory

String

False

Required parameter. Contains the full path to the local directory from which to read the log file or files.

LogFilePattern

String

False

Required parameter. Contains the file name or wildcard pattern to match for the log files.

LogIsUTF8

Boolean

False

Required parameter. Indicates whether the log file is UTF8-encoded. The value should be either true or false.

Separator

String

False

Required parameter. The character that forms the delimiter. Can be in the following forms: , or “,”.

For more information about the LogFileDirectory, LogFilePattern, and LogInUTF8 parameters in this module, see System.ApplicationLog.GenericLogReader.

Remarks

For remarks, see System.ApplicationLog.GenericLogReader.

Composition

The System.ApplicationLog.GenericCSVLogReader module is a composite module that contains the member modules described in the following table.

Workflow Run Order Module Type Usage

1

System.ApplicationLog.GenericCSVLogReader.Internal

Internal module.

Errors

The following errors can occur from within the System.ApplicationLog.GenericCSVLogReader module.

Exception Reason

MSG_APPLOG_DATA_SOURCE_ERROR_ACCESSING_LOG_FILE_DIRECTORY

The log directory specified in the LogFileDirectory parameter cannot be accessed.

MSG_APPLOG_DATA_SOURCE_LOG_FILE_DIRECTORY_HAS_DISAPPEARED

The log directory specified in the LogFileDirectory parameter can no longer be found.

MSG_APPLOG_DATA_SOURCE_ERROR_LOG_FILE_DISAPPEARED

The current log file being processed has suddenly disappeared from the directory.

MSG_APPLOG_DATA_SOURCE_ERROR_ACCESSING_LOG_FILE

The current log file being processed cannot be accessed. The module will continue to try and read the file.

Module Type Usage

System.ApplicationLog.GenericLog.EventProvider

Maps non-delimited, text-based generic log entry data to event data. Returns System.Event.Data data.

System.ApplicationLog.GenericLog.FilteredEventProvider

Maps filtered non-delimited, text-based generic log entry data to event data. Returns System.Event.Data data.

External Module References

The System.ApplicationLog.GenericCSVLogReader module is a member of the modules described in the following table.

Module Type Library Usage

System.ApplicationLog.GenericCSVLog.EventProvider

System.ApplicationLog.Library

Maps delimited, text-based generic log entry data to event data. Returns System.Event.Data data.

System.ApplicationLog.GenericCSVLog.FilteredEventProvider

System.ApplicationLog.Library

Maps filtered and delimited, text-based generic log entry data to event data. Returns System.Event.Data data.

Sample

The following sample illustrates how a rule can be implemented to retrieve generic log entry data from any number of log files in a directory. In this sample, the generic log entry data is mapped to System.Event.Data so that it can be stored in the Operations Manager database. This sample is for illustrative purposes only. Generally, to write log entry data as event data, you would use either the System.ApplicationLog.GenericCSVLog.EventProvider module type or the System.ApplicationLog.GenericCSVLog.FilteredEventProvider module type.

<Rule ID="Microsoft.Samples.LogEntryToEvent" Target="Microsoft.Samples.TheApplication" Enabled="true">
 <DataSources>
    <DataSource ID="LogDS" TypeID="AppLog!System.ApplicationLog.GenericLogReader">
      <LogFileDirectory>C:\logs</LogFileDirectory>
      <LogFilePattern>*.log</LogFilePattern>
      <LogIsUTF8>false</LogIsUTF8>
    </DataSource>
  </DataSources>
  <ConditionDetection TypeID="System!System.Event.GenericDataMapper" ID="Mapper">
    <EventOriginId>$Target/Id$</EventOriginId>
    <PublisherId>$MPElement$</PublisherId>
    <PublisherName>GenericLog</PublisherName>
    <Channel>GenericLog</Channel>
    <LoggingComputer />
    <EventNumber>0</EventNumber>
    <EventCategory>3</EventCategory>
    <EventLevel>0</EventLevel>
    <UserName />
    <Params>
      <Param>$Data/Params/Param[1]$</Param>
    </Params>
  </ConditionDetection>
  <WriteActions>
    <WriteAction ID="WriteToDB" TypeID="SCLibrary!Microsoft.SystemCenter.CollectEvent"/>
    <WriteAction ID="WriteToDW" TypeID="SCDW!Microsoft.SystemCenter.DataWarehouse.PublishEventData"/>
  </WriteActions>

</Rule>

In the preceding sample, the value of the Param element in the mapper module is $Data/Params/Param[1]$, which contains the text of the log entry. The $Data variable notation refers to the data structure that is returned from System.ApplicationLog.GenericCSVLogReader module. If the log entry line is This is the first column in one entry, This is the second column in one entry, the data structure would be something like the following:

<DataItem type="System.ApplicationLog.GenericLogEntryData" time="2008-03-11T03:08:55.0343534-08:00" sourceHealthServiceId="0A0800A0-A802-E90B-6045-D961D516CA78">
  <LogFileDirectory>C:\logs</LogFileDirectory>
  <LogFileType>7</LogFileType>
  <LogFileName>C:\logs\somelog.log</LogFileName>
  <Params>
     <Param>This is the first column in one entry.</Param>
     <Param>This is the second column in one entry.</Param>
  </Params>
</DataItem>

The data item from the generic event mapper would look like the following:

<DataItem type="System.Event.Data" time="2008-03-11T03:08:55.0343534-08:00" sourceHealthServiceId="0A0800A0-A802-E90B-6045-D961D516CA78">
  <EventOriginId>{513C3E6D-374A-47d1-94B6-920EB54F9A27}</EventOriginId>
  <PublisherId>{513C3E6D-374A-47d1-94B6-920EB54F9A27}</PublisherId>
  <PublisherName>GenericLog</PublisherName>
  <Channel>GenericLog</Channel>
  <LoggingComputer />
  <EventNumber>0</EventNumber>
  <EventCategory>3</EventCategory>
  <EventLevel>0</EventLevel>
  <UserName />
  <EventData>
    <DataItem type="System.ApplicationLog.GenericLogEntryData" time="2007-05-22T10:07:41.6416394-07:00" sourceHealthServiceId="A9BB62D3-BEF2-5208-E680-1EE489235408">
      <LogFileDirectory>c:\Logs</LogFileDirectory>
      <LogFileType>Generic CSV Log File Format</LogFileType>
      <LogFileName>c:\Logs\some.log</LogFileName>
      <Params>
         <Param>This is the first column in one entry.</Param>
         <Param>This is the second column in one entry.</Param>
      </Params>
      <DataItem>
  </EventData>
</DataItem>

Information

   

Module Type

DataSourceModuleType

Input Type

None

Output Type

System.ApplicationLog.GenericLogEntryData

Implementation

Composite

Library

System.ApplicationLog.Library