Definición de niveles de gravedad

Los niveles se usan para agrupar eventos y normalmente indican la gravedad o detalle de un evento. Para definir un nivel, use el elemento level . El archivo Winmeta.xml define los siguientes niveles de gravedad usados habitualmente:

  • win:Critical
  • win:Error
  • win:Warning
  • win:Informational
  • win:Verbose

Los consumidores usan niveles para consultar los eventos que contienen un valor de nivel específico. Una sesión de seguimiento ETW también puede usar niveles para limitar los eventos escritos en el archivo de registro de seguimiento de eventos; los eventos con un valor de nivel igual o menor que el valor de nivel especificado se escriben en el archivo de registro. Por ejemplo, si la sesión especificó el valor de nivel para win:Warning, el archivo de registro contendrá eventos de advertencia, error y crítico.

En el ejemplo siguiente se muestra cómo definir un nivel. Debe especificar los atributos de nombre y valor del nivel. El valor del atributo value debe estar en el intervalo comprendido entre 16 y 255. Los atributos de símbolo y mensaje son opcionales.

<instrumentationManifest
    xmlns="http://schemas.microsoft.com/win/2004/08/events" 
    xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    >

    <instrumentation>
        <events>
            <provider name="Microsoft-Windows-SampleProvider"
                guid="{1db28f2e-8f80-4027-8c5a-a11f7f10f62d}"
                symbol="PROVIDER_GUID"
                resourceFileName="<path to the exe or dll that contains the metadata resources>"
                messageFileName="<path to the exe or dll that contains the string resources>"
                message="$(string.Provider.Name)">

                . . .

                <levels>
                    <level name="NotValid"
                           value="16"
                           symbol="LEVEL_SAMPLEPROVIDER_NOTVALID"
                           message="$(string.Level.NotValid)"/>
                    <level name="Valid"
                           value="17"
                           symbol="LEVEL_SAMPLEPROVIDER_VALID"
                           message="$(string.Level.Valid)"/>
                </levels>

                . . .

            </provider>
        </events>
    </instrumentation>

    <localization>
        <resources culture="en-US">
            <stringTable>
                <string id="Provider.Name" value="Sample Provider"/>
                <string id="Level.Valid" value="Valid"/>
                <string id="Level.NotValid" value="Not Valid"/>
            </stringTable>
        </resources>
    </localization>

</instrumentationManifest>