Table of Contents

Class LogEntry

Namespace
Microsoft.Practices.EnterpriseLibrary.Logging
Assembly
Microsoft.Practices.EnterpriseLibrary.Logging.dll

Represents a log message. Contains the common properties that are required for all log messages.

public class LogEntry : ICloneable
Inheritance
LogEntry
Implements
Derived
Inherited Members

Constructors

LogEntry()

Initialize a new instance of a LogEntry class.

public LogEntry()

LogEntry(object, ICollection<string>, int, int, TraceEventType, string, IDictionary<string, object>)

Create a new instance of LogEntry with a full set of constructor parameters

public LogEntry(object message, ICollection<string> categories, int priority, int eventId, TraceEventType severity, string title, IDictionary<string, object> properties)

Parameters

message object

Message body to log. Value from ToString() method from message object.

categories ICollection<string>

Collection of category names used to route the log entry to a one or more sinks.

priority int

Only messages must be above the minimum priority are processed.

eventId int

Event number or identifier.

severity TraceEventType

Log entry severity as a Severity enumeration. (Unspecified, Information, Warning or Error).

title string

Additional description of the log entry message.

properties IDictionary<string, object>

Dictionary of key/value pairs to record.

LogEntry(object, string, int, int, TraceEventType, string, IDictionary<string, object>)

Create a new instance of LogEntry with a full set of constructor parameters

public LogEntry(object message, string category, int priority, int eventId, TraceEventType severity, string title, IDictionary<string, object> properties)

Parameters

message object

Message body to log. Value from ToString() method from message object.

category string

Category name used to route the log entry to a one or more trace listeners.

priority int

Only messages must be above the minimum priority are processed.

eventId int

Event number or identifier.

severity TraceEventType

Log entry severity as a Severity enumeration. (Unspecified, Information, Warning or Error).

title string

Additional description of the log entry message.

properties IDictionary<string, object>

Dictionary of key/value pairs to record.

Properties

ActivityId

Tracing activity id

public Guid ActivityId { get; set; }

Property Value

Guid

ActivityIdString

Tracing activity id as a string to support WMI Queries

public string ActivityIdString { get; }

Property Value

string

AppDomainName

The AppDomain in which the program is running

public string AppDomainName { get; set; }

Property Value

string

Categories

Category name used to route the log entry to a one or more trace listeners.

public ICollection<string> Categories { get; set; }

Property Value

ICollection<string>

CategoriesStrings

Category names used to route the log entry to a one or more trace listeners. This readonly property is available to support WMI queries

public string[] CategoriesStrings { get; }

Property Value

string[]

DefaultTitle

Gets the default title for an entry.

public static string DefaultTitle { get; }

Property Value

string

ErrorMessages

Gets the error message with the LogEntry

public string ErrorMessages { get; }

Property Value

string

EventId

Event number or identifier.

public int EventId { get; set; }

Property Value

int

ExtendedProperties

Dictionary of key/value pairs to record.

public IDictionary<string, object> ExtendedProperties { get; set; }

Property Value

IDictionary<string, object>

LoggedSeverity

Gets the string representation of the Severity enumeration.

public string LoggedSeverity { get; }

Property Value

string

The string value of the Severity enumeration.

MachineName

Name of the computer.

public string MachineName { get; set; }

Property Value

string

ManagedThreadName

The name of the .NET thread.

public string ManagedThreadName { get; set; }

Property Value

string
See Also

Message

Message body to log. Value from ToString() method from message object.

public string Message { get; set; }

Property Value

string

Priority

Importance of the log message. Only messages whose priority is between the minimum and maximum priorities (inclusive) will be processed.

public int Priority { get; set; }

Property Value

int

ProcessId

The Win32 process ID for the current running process.

public string ProcessId { get; set; }

Property Value

string

ProcessName

The name of the current running process.

public string ProcessName { get; set; }

Property Value

string

RelatedActivityId

Related activity id

public Guid? RelatedActivityId { get; set; }

Property Value

Guid?

Severity

Log entry severity as a Severity enumeration. (Unspecified, Information, Warning or Error).

public TraceEventType Severity { get; set; }

Property Value

TraceEventType

TimeStamp

Date and time of the log entry message.

public DateTime TimeStamp { get; set; }

Property Value

DateTime

TimeStampString

Read-only property that returns the timeStamp formatted using the current culture.

public string TimeStampString { get; }

Property Value

string

Title

Additional description of the log entry message.

public string Title { get; set; }

Property Value

string

Win32ThreadId

The Win32 Thread ID for the current thread.

public string Win32ThreadId { get; set; }

Property Value

string

Methods

AddErrorMessage(string)

Add an error or warning message to the start of the messages string builder.

public virtual void AddErrorMessage(string message)

Parameters

message string

Message to be added to this instance

Clone()

Creates a new LogEntry that is a copy of the current instance.

public object Clone()

Returns

object

A new LogEntry that is a copy of the current instance.

Remarks

If the dictionary contained in ExtendedProperties implements ICloneable, the resulting LogEntry will have its ExtendedProperties set by calling Clone(). Otherwise the resulting LogEntry will have its ExtendedProperties set to null.

GetProcessName()

Gets the current process name.

public static string GetProcessName()

Returns

string

The process name.

ToString()

Returns a string that represents the current LogEntry, using a default formatting template.

public override string ToString()

Returns

string

A string that represents the current LogEntry.