TraceSection Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Configura el servicio de seguimiento de ASP.NET. Esta clase no puede heredarse.
public ref class TraceSection sealed : System::Configuration::ConfigurationSection
public sealed class TraceSection : System.Configuration.ConfigurationSection
type TraceSection = class
inherit ConfigurationSection
Public NotInheritable Class TraceSection
Inherits ConfigurationSection
- Herencia
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar el TraceSection tipo .
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Web.Configuration;
namespace Samples.Aspnet.SystemWebConfiguration
{
// Accesses the System.Web.Configuration.TraceSection members
// selected by the user.
class UsingTraceSection
{
public static void Main()
{
// Process the System.Web.Configuration.TraceSectionobject.
try
{
// Get the Web application configuration.
System.Configuration.Configuration configuration =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/aspnet");
// Get the section.
System.Web.Configuration.TraceSection traceSection =
(System.Web.Configuration.TraceSection)
configuration.GetSection("system.web/trace");
// Get the current PageOutput property value.
Boolean pageOutputValue = traceSection.PageOutput;
// Set the PageOutput property to true.
traceSection.PageOutput = true;
// Get the current WriteToDiagnosticsTrace property value.
Boolean writeToDiagnosticsTraceValue = traceSection.WriteToDiagnosticsTrace;
// Set the WriteToDiagnosticsTrace property to true.
traceSection.WriteToDiagnosticsTrace = true;
// Get the current MostRecent property value.
Boolean mostRecentValue = traceSection.MostRecent;
// Set the MostRecent property to true.
traceSection.MostRecent = true;
// Get the current RequestLimit property value.
Int32 requestLimitValue = traceSection.RequestLimit;
// Set the RequestLimit property to 256.
traceSection.RequestLimit = 256;
// Get the current LocalOnly property value.
Boolean localOnlyValue = traceSection.LocalOnly;
// Set the LocalOnly property to false.
traceSection.LocalOnly = false;
// Get the current Enabled property value.
Boolean enabledValue = traceSection.Enabled;
// Set the Enabled property to false.
traceSection.Enabled = false;
// Get the current Mode property value.
// TraceDisplayMode modeValue = traceSection.TraceMode;
// Set the Mode property to TraceDisplayMode.SortyByTime.
// traceSection.Mode = TraceDisplayMode.SortByTime;
// Update if not locked.
if (!traceSection.SectionInformation.IsLocked)
{
configuration.Save();
Console.WriteLine("** Configuration updated.");
}
else
{
Console.WriteLine("** Could not update, section is locked.");
}
}
catch (System.ArgumentException e)
{
// Unknown error.
Console.WriteLine(
"A invalid argument exception detected in UsingTraceSection Main. Check your");
Console.WriteLine("command line for errors.");
}
}
} // UsingTraceSection class end.
} // Samples.Aspnet.SystemWebConfiguration namespace end.
Imports System.Collections
Imports System.Collections.Specialized
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Configuration
Imports System.Web.Configuration
Namespace Samples.Aspnet.SystemWebConfiguration
' Accesses the System.Web.Configuration.TraceSection members
' selected by the user.
Class UsingTraceSection
Public Shared Sub Main()
' Process the System.Web.Configuration.TraceSectionobject.
Try
' Get the Web application configuration.
Dim configuration As System.Configuration.Configuration = _
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/aspnet")
' Get the section.
Dim traceSection As System.Web.Configuration.TraceSection = _
CType(configuration.GetSection("system.web/trace"), _
System.Web.Configuration.TraceSection)
' Get the current PageOutput property value.
Dim pageOutputValue As Boolean = traceSection.PageOutput
' Set the PageOutput property to true.
traceSection.PageOutput = True
' Get the current WriteToDiagnosticsTrace property value.
Dim writeToDiagnosticsTraceValue As Boolean = traceSection.WriteToDiagnosticsTrace
' Set the WriteToDiagnosticsTrace property to true.
traceSection.WriteToDiagnosticsTrace = True
' Get the current MostRecent property value.
Dim mostRecentValue As Boolean = traceSection.MostRecent
' Set the MostRecent property to true.
traceSection.MostRecent = True
' Get the current RequestLimit property value.
Dim requestLimitValue As Int32 = traceSection.RequestLimit
' Set the RequestLimit property to 256.
traceSection.RequestLimit = 256
' Get the current LocalOnly property value.
Dim localOnlyValue As Boolean = traceSection.LocalOnly
' Set the LocalOnly property to false.
traceSection.LocalOnly = False
' Get the current Enabled property value.
Dim enabledValue As Boolean = traceSection.Enabled
' Set the Enabled property to false.
traceSection.Enabled = False
' Get the current Mode property value.
'Dim modeValue As TraceDisplayMode = traceSection.TraceMode
' Set the Mode property to TraceDisplayMode.SortByTime.
'traceSection.Mode = TraceDisplayMode.SortByTime
' Update if not locked.
If Not traceSection.SectionInformation.IsLocked Then
configuration.Save()
Console.WriteLine("** Configuration updated.")
Else
Console.WriteLine("** Could not update, section is locked.")
End If
Catch e As System.ArgumentException
' Unknown error.
Console.WriteLine( _
"A invalid argument exception detected in UsingTraceSection Main. Check your")
Console.WriteLine("command line for errors.")
End Try
End Sub
End Class
End Namespace ' Samples.Aspnet.SystemWebConfiguration
Comentarios
La TraceSection clase proporciona una manera de obtener acceso mediante programación y modificar el contenido de la sección del archivo trace de configuración. La sección trace configura la funcionalidad de seguimiento ASP.NET y controla cómo se recopilan, almacenan y muestran los resultados del seguimiento.
Cuando el seguimiento está habilitado, cada solicitud de página genera mensajes de seguimiento que se pueden anexar a la salida de la página o almacenarlos en un registro de seguimiento de la aplicación. Puede usar el visor de seguimiento de ASP.NET (Trace.axd) para ver el contenido del registro de seguimiento.
Constructores
| Nombre | Description |
|---|---|
| TraceSection() |
Inicializa una nueva instancia de la TraceSection clase con la configuración predeterminada. |
Propiedades
| Nombre | Description |
|---|---|
| CurrentConfiguration |
Obtiene una referencia a la instancia de nivel Configuration superior que representa la jerarquía de configuración a la que pertenece la instancia actual ConfigurationElement . (Heredado de ConfigurationElement) |
| ElementInformation |
Obtiene un ElementInformation objeto que contiene la información y la funcionalidad no personalizables del ConfigurationElement objeto . (Heredado de ConfigurationElement) |
| ElementProperty |
Obtiene el ConfigurationElementProperty objeto que representa el ConfigurationElement propio objeto. (Heredado de ConfigurationElement) |
| Enabled |
Obtiene o establece un valor que indica si el servicio de seguimiento de ASP.NET está habilitado. |
| EvaluationContext |
Obtiene el objeto ContextInformation para el objeto ConfigurationElement. (Heredado de ConfigurationElement) |
| HasContext |
Obtiene un valor que indica si la CurrentConfiguration propiedad es |
| Item[ConfigurationProperty] |
Obtiene o establece una propiedad o atributo de este elemento de configuración. (Heredado de ConfigurationElement) |
| Item[String] |
Obtiene o establece una propiedad, un atributo o un elemento secundario de este elemento de configuración. (Heredado de ConfigurationElement) |
| LocalOnly |
Obtiene o establece un valor que indica si el visor de seguimiento de ASP.NET (Trace.axd) solo está disponible para las solicitudes del servidor web host. |
| LockAllAttributesExcept |
Obtiene la colección de atributos bloqueados. (Heredado de ConfigurationElement) |
| LockAllElementsExcept |
Obtiene la colección de elementos bloqueados. (Heredado de ConfigurationElement) |
| LockAttributes |
Obtiene la colección de atributos bloqueados. (Heredado de ConfigurationElement) |
| LockElements |
Obtiene la colección de elementos bloqueados. (Heredado de ConfigurationElement) |
| LockItem |
Obtiene o establece un valor que indica si el elemento está bloqueado. (Heredado de ConfigurationElement) |
| MostRecent |
Obtiene o establece un valor que indica si las solicitudes más recientes siempre se almacenan en el servidor. |
| PageOutput |
Obtiene o establece un valor que indica si la información de seguimiento ASP.NET se anexa a la salida de cada página. |
| Properties |
Obtiene la colección de propiedades. (Heredado de ConfigurationElement) |
| RequestLimit |
Obtiene o establece un valor que indica el número máximo de solicitudes a la aplicación para la que ASP.NET almacena información de seguimiento. |
| SectionInformation |
Obtiene un objeto SectionInformation que contiene la información y la funcionalidad no personalizables del objeto ConfigurationSection. (Heredado de ConfigurationSection) |
| TraceMode |
Obtiene o establece el orden en el que se muestra ASP.NET información de seguimiento. |
| WriteToDiagnosticsTrace |
Obtiene o establece un valor que indica si los mensajes emitidos a través del seguimiento de página se reenvían a una instancia de la Trace clase . |
Métodos
| Nombre | Description |
|---|---|
| DeserializeElement(XmlReader, Boolean) |
Lee XML del archivo de configuración. (Heredado de ConfigurationElement) |
| DeserializeSection(XmlReader) |
Lee XML del archivo de configuración. (Heredado de ConfigurationSection) |
| Equals(Object) |
Compara la instancia de ConfigurationElement actual con el objeto especificado. (Heredado de ConfigurationElement) |
| GetHashCode() |
Obtiene un valor único que representa la instancia de ConfigurationElement actual. (Heredado de ConfigurationElement) |
| GetRuntimeObject() |
Devuelve un objeto personalizado cuando se invalida en una clase derivada. (Heredado de ConfigurationSection) |
| GetTransformedAssemblyString(String) |
Devuelve la versión transformada del nombre de ensamblado especificado. (Heredado de ConfigurationElement) |
| GetTransformedTypeString(String) |
Devuelve la versión transformada del nombre de tipo especificado. (Heredado de ConfigurationElement) |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| Init() |
Establece el ConfigurationElement objeto en su estado inicial. (Heredado de ConfigurationElement) |
| InitializeDefault() |
Se usa para inicializar un conjunto predeterminado de valores para el ConfigurationElement objeto . (Heredado de ConfigurationElement) |
| IsModified() |
Indica si este elemento de configuración se ha modificado desde que se guardó o cargó por última vez cuando se implementó en una clase derivada. (Heredado de ConfigurationSection) |
| IsReadOnly() |
Obtiene un valor que indica si el objeto ConfigurationElement es de solo lectura. (Heredado de ConfigurationElement) |
| ListErrors(IList) |
Agrega los errores de propiedad no válida en este ConfigurationElement objeto y, en todos los subelementos, a la lista pasada. (Heredado de ConfigurationElement) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Obtiene un valor que indica si se encuentra un atributo desconocido durante la deserialización. (Heredado de ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Obtiene un valor que indica si se encuentra un elemento desconocido durante la deserialización. (Heredado de ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Produce una excepción cuando no se encuentra una propiedad necesaria. (Heredado de ConfigurationElement) |
| PostDeserialize() |
Se llama después de la deserialización. (Heredado de ConfigurationElement) |
| PreSerialize(XmlWriter) |
Se llama antes de la serialización. (Heredado de ConfigurationElement) |
| Reset(ConfigurationElement) |
Restablece el estado interno del objeto ConfigurationElement, incluidos los bloqueos y las colecciones de propiedades. (Heredado de ConfigurationElement) |
| ResetModified() |
Restablece el valor del método IsModified() a |
| SerializeElement(XmlWriter, Boolean) |
Escribe el contenido de este elemento de configuración en el archivo de configuración cuando se implementa en una clase derivada. (Heredado de ConfigurationElement) |
| SerializeSection(ConfigurationElement, String, ConfigurationSaveMode) |
Crea una cadena XML que contiene una vista no combinada del objeto ConfigurationSection como una sola sección para escribir en un archivo. (Heredado de ConfigurationSection) |
| SerializeToXmlElement(XmlWriter, String) |
Escribe las etiquetas externas de este elemento de configuración en el archivo de configuración cuando se implementa en una clase derivada. (Heredado de ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Establece una propiedad en el valor especificado. (Heredado de ConfigurationElement) |
| SetReadOnly() |
Establece la propiedad IsReadOnly() para el objeto ConfigurationElement y todos los subelementos. (Heredado de ConfigurationElement) |
| ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) |
Indica si el elemento especificado se debe serializar cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework. (Heredado de ConfigurationSection) |
| ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement) |
Indica si la propiedad especificada se debe serializar cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework. (Heredado de ConfigurationSection) |
| ShouldSerializeSectionInTargetVersion(FrameworkName) |
Indica si se debe serializar la instancia de ConfigurationSection actual cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework. (Heredado de ConfigurationSection) |
| ToString() |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Modifica el objeto ConfigurationElement para quitar todos los valores que no se deben guardar. (Heredado de ConfigurationElement) |