LoggingEventSource Sınıf

Tanım

LoggingEventSource, tüm ILogger tabanlı günlük kaydı için EventSource/EventListener günlüğüne olan köprüdir.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
Devralma
LoggingEventSource
Öznitelikler

Örnekler

Aşağıdaki örnek, bir EventListener 'ın, bu bilgileri almak için nasıl kullanılacağını gösterir: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]);
    }
}

Açıklamalar

Bu oturum açmayı, EventSource adlı EventSource öğesini etkinleştirerek açabilirsiniz Microsoft-Extensions-Logging .You turn this logging on by enabling the EventSource called Microsoft-Extensions-Logging.

EventSource 'u etkinleştirdiğinizde, ayarladığınız EventLevel, ıllogger ile ilişkili düzeye (Bu nedenle Debug = verbose, bilgilendirici = bilgilendirici...) açık şekilde çevrilir. Kritik = = kritik)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)

Bu, olay düzeyine göre kolay bir şekilde filtrelemenize olanak sağlar.This allows you to filter by event level in a straightforward way.

Daha hassas denetim için adlı bir EventSource bağımsız değişkeni belirtebilirsiniz FilterSpecs .For finer control you can specify a EventSource Argument called FilterSpecs.

FilterSpecsBağımsız değişkeni, belirtimlerin noktalı virgülle ayrılmış listesidir.The FilterSpecs argument is a semicolon separated list of specifications. Her belirtimWhere 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).

Burada ad, bir IBir IBir ı' ın adıdır (büyük/küçük harf önemli), ad bir * SONEK olarak joker karakter görevi gören bir olabilir.Where Name is the name of a ILoggger (case matters), Name can have a * which acts as a wildcard AS A SUFFIX. Bu nedenle, net * ' net ' ile başlayan tüm Günlükçüler ile eşleşmeyecektir.Thus, Net* will match any loggers that start with the 'Net'.

DÜZEY bir sayı veya LogLevel dizesidir.The LEVEL is a number or a LogLevel string. 0 = izleme, 1 = hata ayıklama, 2 = bilgi, 3 = uyarı, 4 = hata, kritik = 5 Bu, ilişkili düzenin düzeyini belirtir.0=Trace, 1=Debug, 2=Information, 3=Warning, 4=Error, Critical=5 This specifies the level for the associated pattern. Numara belirtilmemişse, (belirtimin ilk biçimi) EventSource için varsayılan düzeydir.If the number is not specified, (first form of the specification) it is the default level for the EventSource.

Belirli bir ad birden fazla Düzenle eşleşiyorsa ilk eşleşme kullanılır.First match is used if a particular name matches more than one pattern.

Level ve FilterSpec bağımsız değişkenine ek olarak, EventSource anahtar sözcüklerini de ayarlayabilirsiniz.In addition to the level and FilterSpec argument, you can also set EventSource Keywords. Aşağıdaki anahtar sözcük tanımına bakın, ancak temel olarakSee the Keywords definition below, but basically you get to decide if you wish to have

  • Anahtar sözcükler. Ileti-olayı ayrıştırılmış form ile alırsınız.Keywords.Message - You get the event with the data in parsed form.
  • Keywords.JsonMessage-verileri ayrıştırma formunda, ancak JSON blobu olarak (bağımsız değişkene göre kopuk...) içeren bir olay alırsınız.Keywords.JsonMessage - you get an event with the data in parse form but as a JSON blob (not broken up by argument ...)
  • Keywords. FormattedMessage-dize olarak biçimlendirilen verilerle bir olay alırsınızKeywords.FormattedMessage - you get an event with the data formatted as a string

Tek seferde bu anahtar sözcüklerden yalnızca birini açmanız beklenmektedir, ancak bunları açabilir ve aynı verileri üç farklı yolla günlüğe alabilirsiniz.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.

Özellikler

ConstructionException

Olay kaynağının oluşturulması sırasında oluşturulan herhangi bir özel durumu alır.Gets any exception that was thrown during the construction of the event source.

(Devralındığı yer: EventSource)
Guid

Olay kaynağı için benzersiz tanımlayıcı.The unique identifier for the event source.

(Devralındığı yer: EventSource)
Name

Olay kaynağından türetilen sınıfın kolay adı.The friendly name of the class that is derived from the event source.

(Devralındığı yer: EventSource)
Settings

Bu olay kaynağına uygulanan ayarları alır.Gets the settings applied to this event source.

(Devralındığı yer: EventSource)

Yöntemler

Dispose()

EventSource sınıfının geçerli örneği tarafından kullanılan tüm kaynakları serbest bırakır.Releases all resources used by the current instance of the EventSource class.

(Devralındığı yer: EventSource)
Dispose(Boolean)

Sınıfı tarafından kullanılan yönetilmeyen kaynakları serbest bırakır EventSource ve isteğe bağlı olarak yönetilen kaynakları yayınlar.Releases the unmanaged resources used by the EventSource class and optionally releases the managed resources.

(Devralındığı yer: EventSource)
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.Determines whether the specified object is equal to the current object.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi olarak işlev görür.Serves as the default hash function.

(Devralındığı yer: Object)
GetType()

TypeGeçerli örneği alır.Gets the Type of the current instance.

(Devralındığı yer: Object)
IsEnabled()

Geçerli olay kaynağının etkinleştirilip etkinleştirilmediğini belirler.Determines whether the current event source is enabled.

(Devralındığı yer: EventSource)
IsEnabled(EventLevel, EventKeywords)

Belirtilen düzeye ve anahtar sözcüğüne sahip olan geçerli olay kaynağının etkinleştirilip etkinleştirilmediğini belirler.Determines whether the current event source that has the specified level and keyword is enabled.

(Devralındığı yer: EventSource)
IsEnabled(EventLevel, EventKeywords, EventChannel)

Belirtilen düzeye, anahtar sözcüklere ve kanala sahip olaylar için geçerli olay kaynağının etkinleştirilip etkinleştirilmediğini belirler.Determines whether the current event source is enabled for events with the specified level, keywords and channel.

(Devralındığı yer: EventSource)
MemberwiseClone()

Geçerli bir basit kopyasını oluşturur Object .Creates a shallow copy of the current Object.

(Devralındığı yer: Object)
OnEventCommand(EventCommandEventArgs)

Geçerli olay kaynağı denetleyici tarafından güncelleniyorsa çağırılır.Called when the current event source is updated by the controller.

(Devralındığı yer: EventSource)
ToString()

Geçerli olay kaynağı örneğinin dize gösterimini edinir.Obtains a string representation of the current event source instance.

(Devralındığı yer: EventSource)
Write(String)

Alanlar olmadan bir olay yazar, ancak belirtilen ad ve varsayılan seçeneklere sahiptir.Writes an event without fields, but with the specified name and default options.

(Devralındığı yer: EventSource)
Write(String, EventSourceOptions)

Alanları olmayan bir olayı, ancak belirtilen ad ve seçeneklere yazar.Writes an event without fields, but with the specified name and options.

(Devralındığı yer: EventSource)
Write<T>(String, EventSourceOptions, Guid, Guid, T)

Belirtilen ad, Seçenekler, ilgili etkinlik ve olay verileriyle bir olay yazar.Writes an event with the specified name, options, related activity and event data.

(Devralındığı yer: EventSource)
Write<T>(String, EventSourceOptions, T)

Belirtilen ad, olay verileri ve seçeneklere sahip bir olay yazar.Writes an event with the specified name, event data and options.

(Devralındığı yer: EventSource)
Write<T>(String, EventSourceOptions, T)

Belirtilen ad, seçenek ve olay verileriyle bir olay yazar.Writes an event with the specified name, options and event data.

(Devralındığı yer: EventSource)
Write<T>(String, T)

Belirtilen ad ve verilerle bir olay yazar.Writes an event with the specified name and data.

(Devralındığı yer: EventSource)
WriteEvent(Int32)

Belirtilen olay tanımlayıcısını kullanarak bir olay yazar.Writes an event by using the provided event identifier.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Byte[])

Belirtilen olay tanımlayıcısı ve byte dizi bağımsız değişkenini kullanarak bir olay yazar.Writes an event by using the provided event identifier and byte array argument.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int32)

Belirtilen olay tanımlayıcısını ve 32 bitlik tamsayı bağımsız değişkenini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 32-bit integer argument.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int32, Int32)

Belirtilen olay tanımlayıcısını ve 32 bitlik tamsayı bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 32-bit integer arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int32, Int32, Int32)

Belirtilen olay tanımlayıcısını ve 32 bitlik tamsayı bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 32-bit integer arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int32, String)

Belirtilen olay tanımlayıcısını ve 32 bitlik tamsayı ve dize bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 32-bit integer and string arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int64)

Belirtilen olay tanımlayıcısını ve 64 bitlik tamsayı bağımsız değişkenini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 64-bit integer argument.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int64, Byte[])

Belirtilen tanımlayıcıyı ve 64-bit tamsayı ve byte dizi bağımsız değişkenlerini kullanarak olay verilerini yazar.Writes the event data using the specified identifier and 64-bit integer and byte array arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int64, Int64)

Belirtilen olay tanımlayıcısını ve 64 bit bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 64-bit arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int64, Int64, Int64)

Belirtilen olay tanımlayıcısını ve 64 bit bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 64-bit arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Int64, String)

Belirtilen olay tanımlayıcısını ve 64 bitlik tamsayıyı ve dize bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and 64-bit integer, and string arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, Object[])

Belirtilen olay tanımlayıcısını ve bağımsız değişken dizisini kullanarak bir olay yazar.Writes an event by using the provided event identifier and array of arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, String)

Belirtilen olay tanımlayıcısını ve dize bağımsız değişkenini kullanarak bir olay yazar.Writes an event by using the provided event identifier and string argument.

(Devralındığı yer: EventSource)
WriteEvent(Int32, String, Int32)

Belirtilen olay tanımlayıcısını ve bağımsız değişkenleri kullanarak bir olay yazar.Writes an event by using the provided event identifier and arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, String, Int32, Int32)

Belirtilen olay tanımlayıcısını ve bağımsız değişkenleri kullanarak bir olay yazar.Writes an event by using the provided event identifier and arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, String, Int64)

Belirtilen olay tanımlayıcısını ve bağımsız değişkenleri kullanarak bir olay yazar.Writes an event by using the provided event identifier and arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, String, String)

Belirtilen olay tanımlayıcısını ve dize bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and string arguments.

(Devralındığı yer: EventSource)
WriteEvent(Int32, String, String, String)

Belirtilen olay tanımlayıcısını ve dize bağımsız değişkenlerini kullanarak bir olay yazar.Writes an event by using the provided event identifier and string arguments.

(Devralındığı yer: EventSource)
WriteEventCore(Int32, Int32, EventSource+EventData*)

WriteEventBelirtilen olay tanımlayıcısını ve olay verilerini kullanarak yeni bir aşırı yükleme oluşturur.Creates a new WriteEvent overload by using the provided event identifier and event data.

(Devralındığı yer: EventSource)
WriteEventWithRelatedActivityId(Int32, Guid, Object[])

Geçerli etkinliğin başka bir etkinlikle ilgili olduğunu belirten bir olay yazar.Writes an event that indicates that the current activity is related to another activity.

(Devralındığı yer: EventSource)
WriteEventWithRelatedActivityIdCore(Int32, Guid*, Int32, EventSource+EventData*)

Geçerli etkinliğin başka bir etkinlikle ilgili olduğunu belirten bir olay yazar.Writes an event that indicates that the current activity is related to another activity.

(Devralındığı yer: EventSource)

Ekinlikler

EventCommandExecuted

Bir komut bir olay dinleyicisinden geldiğinde gerçekleşir.Occurs when a command comes from an event listener.

(Devralındığı yer: EventSource)

Şunlara uygulanır