EventLogSession.ExportLogAndMessages Method

Definition

Exports events and their messages into an external log file.

Overloads

ExportLogAndMessages(String, PathType, String, String)

Exports events and their messages into an external log file.

ExportLogAndMessages(String, PathType, String, String, Boolean, CultureInfo)

Exports events and their messages into an external log file. A flag can be set to indicate that the method will continue exporting events even if the specified query fails for some logs. The event messages are exported in the specified language.

ExportLogAndMessages(String, PathType, String, String)

Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs

Exports events and their messages into an external log file.

C#
public void ExportLogAndMessages(string path, System.Diagnostics.Eventing.Reader.PathType pathType, string query, string targetFilePath);

Parameters

path
String

The name of the event log to export events from, or the path to the event log file to export events from.

pathType
PathType

Specifies whether the string used in the path parameter specifies the name of an event log, or the path to an event log file.

query
String

The query used to select the events to export. Only the events returned from the query will be exported.

targetFilePath
String

The path to the log file (ends in .evtx) in which the exported events will be stored after this method is executed.

Examples

For example code using this class, see How to: Export, Archive, and Clear Event Logs.

Remarks

The event messages are exported in the default language.

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

ExportLogAndMessages(String, PathType, String, String, Boolean, CultureInfo)

Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs
Source:
EventLogSession.cs

Exports events and their messages into an external log file. A flag can be set to indicate that the method will continue exporting events even if the specified query fails for some logs. The event messages are exported in the specified language.

C#
public void ExportLogAndMessages(string path, System.Diagnostics.Eventing.Reader.PathType pathType, string query, string targetFilePath, bool tolerateQueryErrors, System.Globalization.CultureInfo targetCultureInfo);

Parameters

path
String

The name of the event log to export events from, or the path to the event log file to export events from.

pathType
PathType

Specifies whether the string used in the path parameter specifies the name of an event log, or the path to an event log file.

query
String

The query used to select the events to export. Only the events returned from the query will be exported.

targetFilePath
String

The path to the log file (ends in .evtx) in which the exported events will be stored after this method is executed.

tolerateQueryErrors
Boolean

true indicates that the method will continue exporting events even if the specified query fails for some logs, and false indicates that this method will not continue to export events when the specified query fails.

targetCultureInfo
CultureInfo

The culture that specifies which language that the exported event messages will be in.

Examples

For example code using this class, see How to: Export, Archive, and Clear Event Logs.

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10