LoggingEventSource Clase

Definición

LoggingEventSource es el puente al registro de EventSource/EventListener de todos los registros basados en ILogger.The LoggingEventSource is the bridge from all ILogger based logging to EventSource/EventListener logging.

public ref class LoggingEventSource sealed : System::Diagnostics::Tracing::EventSource
[System.Diagnostics.Tracing.EventSource(Name="Microsoft-Extensions-Logging")]
public sealed class LoggingEventSource : System.Diagnostics.Tracing.EventSource
[<System.Diagnostics.Tracing.EventSource(Name="Microsoft-Extensions-Logging")>]
type LoggingEventSource = class
    inherit EventSource
Public NotInheritable Class LoggingEventSource
Inherits EventSource
Herencia
LoggingEventSource
Atributos

Ejemplos

En el ejemplo siguiente se muestra cómo usar EventListener para obtener información de ILogging:The following example shows how to use an EventListener to get ILogging information:

class MyEventListener : EventListener 
{
    protected override void OnEventSourceCreated(EventSource eventSource) 
    {
        if (eventSource.Name == "Microsoft-Extensions-Logging") 
        {
            // initialize a string, string dictionary of arguments to pass to the EventSource.
            // Turn on loggers matching App* to Information, everything else (*) is the default level (which is EventLevel.Error)
            var args = new Dictionary<string, string>() { { "FilterSpecs", "App*:Information;*" } };
            // Set the default level (verbosity) to Error, and only ask for the formatted messages in this case.
            EnableEvents(eventSource, EventLevel.Error, LoggingEventSource.Keywords.FormattedMessage, args);
        }
    }

    protected override void OnEventWritten(EventWrittenEventArgs eventData) 
    {
        // Look for the formatted message event, which has the following argument layout (as defined in the LoggingEventSource.
        // FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, string EventId, string FormattedMessage);
        if (eventData.EventName == "FormattedMessage")
            Console.WriteLine("Logger {0}: {1}", eventData.Payload[2], eventData.Payload[4]);
    }
}

Comentarios

Active este registro habilitando el EventSource llamado Microsoft-Extensions-Logging .You turn this logging on by enabling the EventSource called Microsoft-Extensions-Logging.

Al habilitar EventSource, el EventLevel que establezca se traducirá de la manera obvia al nivel asociado con ILogger (por lo tanto, Debug = verbose, informativo = informativo... Crítico = = crítico)When you enabled the EventSource, the EventLevel you set is translated in the obvious way to the level associated with the ILogger (thus Debug = verbose, Informational = Informational ... Critical == Critical)

Esto permite filtrar por nivel de evento de una manera sencilla.This allows you to filter by event level in a straightforward way.

Para un control más preciso, puede especificar un argumento EventSource denominado FilterSpecs .For finer control you can specify a EventSource Argument called FilterSpecs.

El FilterSpecs argumento es una lista separada por punto y coma de especificaciones.The FilterSpecs argument is a semicolon separated list of specifications. Donde cada especificación esWhere each specification is

SPEC =                          // empty spec, same as *
     | NAME                     // Just a name the level is the default level
     | NAME : LEVEL            // specifies level for a particular logger (can have a * suffix).

Donde name es el nombre de un ILoggger (Case Matt), Name puede tener un * que actúa como un carácter comodín como sufijo.Where Name is the name of a ILoggger (case matters), Name can have a * which acts as a wildcard AS A SUFFIX. Por lo tanto, net * coincidirá con cualquier registrador que empiece por "net".Thus, Net* will match any loggers that start with the 'Net'.

LEVEL es un número o una cadena LogLevel.The LEVEL is a number or a LogLevel string. 0=Trace, 1=Debug, 2=Information, 3=Warning, 4=Error, Critical=5 Esto especifica el nivel del patrón asociado.0=Trace, 1=Debug, 2=Information, 3=Warning, 4=Error, Critical=5 This specifies the level for the associated pattern. Si no se especifica el número (el primer formato de la especificación) es el nivel predeterminado para EventSource.If the number is not specified, (first form of the specification) it is the default level for the EventSource.

Se usa la primera coincidencia si un nombre determinado coincide con más de un patrón.First match is used if a particular name matches more than one pattern.

Además del argumento Level y FilterSpec, también puede establecer palabras clave EventSource.In addition to the level and FilterSpec argument, you can also set EventSource Keywords. Vea la definición de las palabras clave siguiente, pero básicamente puede decidir si quiere tenerSee the Keywords definition below, but basically you get to decide if you wish to have

  • Keywords. Message: obtiene el evento con los datos en formato analizado.Keywords.Message - You get the event with the data in parsed form.
  • Keywords.Jsel mensaje: obtiene un evento con los datos en forma de análisis, pero como un BLOB JSON (no se divide por argumento...)Keywords.JsonMessage - you get an event with the data in parse form but as a JSON blob (not broken up by argument ...)
  • Keywords. FormattedMessage: obtiene un evento con los datos con formato de cadena.Keywords.FormattedMessage - you get an event with the data formatted as a string

Se espera que solo se active una de estas palabras clave a la vez, pero puede activarlas todas y obtener los mismos datos registrados de tres maneras diferentes.It is expected that you will turn only one of these keywords on at a time, but you can turn them all on and get the same data logged three different ways.

Propiedades

ConstructionException

Obtiene cualquier excepción que se produjo durante la construcción de un origen de eventos.Gets any exception that was thrown during the construction of the event source.

(Heredado de EventSource)
Guid

Identificador único para el origen de eventos.The unique identifier for the event source.

(Heredado de EventSource)
Name

Nombre descriptivo de la clase que se deriva del origen de eventos.The friendly name of the class that is derived from the event source.

(Heredado de EventSource)
Settings

Obtiene la configuración aplicada a este origen del evento.Gets the settings applied to this event source.

(Heredado de EventSource)

Métodos

Dispose()

Libera todos los recursos usados por la instancia actual de la clase EventSource.Releases all resources used by the current instance of the EventSource class.

(Heredado de EventSource)
Dispose(Boolean)

Libera los recursos no administrados utilizados por la clase EventSource y, de forma opcional, libera los recursos administrados.Releases the unmanaged resources used by the EventSource class and optionally releases the managed resources.

(Heredado de EventSource)
Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.Determines whether the specified object is equal to the current object.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Heredado de Object)
IsEnabled()

Determina si el origen de eventos actual está habilitado.Determines whether the current event source is enabled.

(Heredado de EventSource)
IsEnabled(EventLevel, EventKeywords)

Determina si el origen de eventos actual que tiene el nivel y la palabra clave especificados está habilitado.Determines whether the current event source that has the specified level and keyword is enabled.

(Heredado de EventSource)
IsEnabled(EventLevel, EventKeywords, EventChannel)

Determina si el origen del evento actual está habilitado para eventos con el nivel, las palabras clave y el canal especificados.Determines whether the current event source is enabled for events with the specified level, keywords and channel.

(Heredado de EventSource)
MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Heredado de Object)
OnEventCommand(EventCommandEventArgs)

Se llama cuando el origen de eventos actual es actualizado por el controlador.Called when the current event source is updated by the controller.

(Heredado de EventSource)
ToString()

Obtiene una representación de cadena de la instancia del origen de eventos actual.Obtains a string representation of the current event source instance.

(Heredado de EventSource)
Write(String)

Escribe un evento sin campos, pero con el nombre especificado y las opciones predeterminadas.Writes an event without fields, but with the specified name and default options.

(Heredado de EventSource)
Write(String, EventSourceOptions)

Escribe un evento sin campos, pero con el nombre y las opciones especificados.Writes an event without fields, but with the specified name and options.

(Heredado de EventSource)
Write<T>(String, EventSourceOptions, Guid, Guid, T)

Escribe un evento con el nombre, las opciones, la actividad relacionada y los datos de evento especificados.Writes an event with the specified name, options, related activity and event data.

(Heredado de EventSource)
Write<T>(String, EventSourceOptions, T)

Escribe un evento con el nombre, los datos de evento y las opciones especificados.Writes an event with the specified name, event data and options.

(Heredado de EventSource)
Write<T>(String, EventSourceOptions, T)

Escribe un evento con el nombre, las opciones y los datos de evento especificados.Writes an event with the specified name, options and event data.

(Heredado de EventSource)
Write<T>(String, T)

Escribe un evento con el nombre y los datos especificados.Writes an event with the specified name and data.

(Heredado de EventSource)
WriteEvent(Int32)

Escribe un evento con el identificador de eventos proporcionado.Writes an event by using the provided event identifier.

(Heredado de EventSource)
WriteEvent(Int32, Byte[])

Escribe un evento con el identificador de eventos y el argumento de matriz de bytes especificados.Writes an event by using the provided event identifier and byte array argument.

(Heredado de EventSource)
WriteEvent(Int32, Int32)

Escribe un evento con el identificador de eventos y el argumento entero de 32 bits especificados.Writes an event by using the provided event identifier and 32-bit integer argument.

(Heredado de EventSource)
WriteEvent(Int32, Int32, Int32)

Escribe un evento con el identificador de eventos y los argumentos enteros de 32 bits especificados.Writes an event by using the provided event identifier and 32-bit integer arguments.

(Heredado de EventSource)
WriteEvent(Int32, Int32, Int32, Int32)

Escribe un evento con el identificador de eventos y los argumentos enteros de 32 bits especificados.Writes an event by using the provided event identifier and 32-bit integer arguments.

(Heredado de EventSource)
WriteEvent(Int32, Int32, String)

Escribe un evento con el identificador de eventos y los argumentos de cadena y enteros de 32 bits especificados.Writes an event by using the provided event identifier and 32-bit integer and string arguments.

(Heredado de EventSource)
WriteEvent(Int32, Int64)

Escribe un evento con el identificador de eventos y el argumento entero de 64 bits especificados.Writes an event by using the provided event identifier and 64-bit integer argument.

(Heredado de EventSource)
WriteEvent(Int32, Int64, Byte[])

Escribe los datos del evento con el identificador y los argumentos de matriz de bytes y enteros de 64 bits especificados.Writes the event data using the specified identifier and 64-bit integer and byte array arguments.

(Heredado de EventSource)
WriteEvent(Int32, Int64, Int64)

Escribe un evento con el identificador de eventos y los argumentos de 64 bits especificados.Writes an event by using the provided event identifier and 64-bit arguments.

(Heredado de EventSource)
WriteEvent(Int32, Int64, Int64, Int64)

Escribe un evento con el identificador de eventos y los argumentos de 64 bits especificados.Writes an event by using the provided event identifier and 64-bit arguments.

(Heredado de EventSource)
WriteEvent(Int32, Int64, String)

Escribe un evento con el identificador de eventos y los argumentos de cadena y enteros de 64 bits especificados.Writes an event by using the provided event identifier and 64-bit integer, and string arguments.

(Heredado de EventSource)
WriteEvent(Int32, Object[])

Escribe un evento con el identificador de eventos y la matriz de argumentos especificados.Writes an event by using the provided event identifier and array of arguments.

(Heredado de EventSource)
WriteEvent(Int32, String)

Escribe un evento con el identificador de eventos y el argumento de cadena especificados.Writes an event by using the provided event identifier and string argument.

(Heredado de EventSource)
WriteEvent(Int32, String, Int32)

Escribe un evento con el identificador de eventos y los argumentos especificados.Writes an event by using the provided event identifier and arguments.

(Heredado de EventSource)
WriteEvent(Int32, String, Int32, Int32)

Escribe un evento con el identificador de eventos y los argumentos especificados.Writes an event by using the provided event identifier and arguments.

(Heredado de EventSource)
WriteEvent(Int32, String, Int64)

Escribe un evento con el identificador de eventos y los argumentos especificados.Writes an event by using the provided event identifier and arguments.

(Heredado de EventSource)
WriteEvent(Int32, String, String)

Escribe un evento con el identificador de eventos y los argumentos de cadena especificados.Writes an event by using the provided event identifier and string arguments.

(Heredado de EventSource)
WriteEvent(Int32, String, String, String)

Escribe un evento con el identificador de eventos y los argumentos de cadena especificados.Writes an event by using the provided event identifier and string arguments.

(Heredado de EventSource)
WriteEventCore(Int32, Int32, EventSource+EventData*)

Crea una nueva sobrecarga de WriteEvent usando el identificador de eventos y los datos de eventos proporcionados.Creates a new WriteEvent overload by using the provided event identifier and event data.

(Heredado de EventSource)
WriteEventWithRelatedActivityId(Int32, Guid, Object[])

Escribe un evento que indica que la actividad actual se relaciona con otra actividad.Writes an event that indicates that the current activity is related to another activity.

(Heredado de EventSource)
WriteEventWithRelatedActivityIdCore(Int32, Guid*, Int32, EventSource+EventData*)

Escribe un evento que indica que la actividad actual se relaciona con otra actividad.Writes an event that indicates that the current activity is related to another activity.

(Heredado de EventSource)

Eventos

EventCommandExecuted

Se produce cuando un comando proviene de un agente de escucha de eventos.Occurs when a command comes from an event listener.

(Heredado de EventSource)

Se aplica a