EventLog Class

MSBuild Extension Pack

EventLog Class MSBuild Extension Pack Help 4.0.12.0
Valid TaskActions are:

Backup (Required: LogName, BackupPath Optional: MachineName)

CheckExists (Required: LogName Optional: MachineName Output: Exists)

Clear (Required: LogName Optional: MachineName)

Create (Required: LogName Optional: MaxSize, Retention, MachineName, CategoryCount, MessageResourceFile, CategoryResourceFile, ParameterResourceFile)

Delete (Required: LogName Optional: MachineName)

Modify (Required: LogName Optional: MaxSize, Retention, MachineName)

Remote Execution Support: Yes

Inheritance Hierarchy

SystemObject  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.ComputerEventLog

Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

The EventLog type exposes the following members.

Constructors

  NameDescription
Public methodEventLog
Top
Properties

  NameDescription
Public propertyBackupPath
Sets the Backup Path
Public propertyCategoryCount
Sets the number of categories in the category resource file
Public propertyCategoryResourceFile
Sets the path of the category resource file to write events with localized category strings
Public propertyExists
Gets a value indicating whether the event log exists.
Public propertyLogName
Sets the name of the Event Log
Public propertyMaxSize
Sets the size of the max.
Public propertyMessageResourceFile
Sets the path of the message resource file to configure an event log source to write localized event messages
Public propertyParameterResourceFile
Sets the path of the parameter resource file to configure an event log source to write localized event messages with inserted parameter strings
Public propertyRetention
Sets the retention. Any value > 0 is interpreted as days to retain. Use -1 for 'Overwrite as needed'. Use -2 for 'Never Overwrite'
Top
Examples

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <Target Name="Default">
        <!-- Backup an eventlog -->
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="Backup" LogName="Security" BackupPath="C:\Securitybackup.evt"/>
        <!-- Delete an eventlog -->
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="Delete" LogName="DemoEventLog"/>
        <!-- Check whether an eventlog exists -->
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="CheckExists" LogName="DemoEventLog">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.EventLog>
        <Message Text="DemoEventLog Exists: $(DoesExist)"/>
        <!-- Create whether an eventlog -->
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="Create" LogName="DemoEventLog"  MaxSize="20" Retention="14"/>
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="CheckExists" LogName="DemoEventLog">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.EventLog>
        <Message Text="DemoEventLog Exists: $(DoesExist)"/>
        <!-- Various other quick tasks -->
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="Clear" LogName="DemoEventLog"/>
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="Modify" LogName="DemoEventLog"  MaxSize="55" Retention="25"/>
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="Delete" LogName="DemoEventLog"/>
        <MSBuild.ExtensionPack.Computer.EventLog TaskAction="CheckExists" LogName="DemoEventLog">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.EventLog>
        <Message Text="Exists: $(DoesExist)"/>
    </Target>
</Project>
See Also

Reference