Udostępnij przez


TraceSection Klasa

Definicja

Konfiguruje usługę śledzenia ASP.NET. Klasa ta nie może być dziedziczona.

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
Dziedziczenie

Przykłady

W poniższym przykładzie kodu pokazano, jak używać TraceSection typu.

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

Uwagi

Klasa TraceSection umożliwia programowy dostęp i modyfikowanie zawartości sekcji pliku trace konfiguracji. Sekcja trace konfiguruje funkcje śledzenia ASP.NET i kontroluje sposób zbierania, przechowywania i wyświetlania wyników śledzenia.

Po włączeniu śledzenia każde żądanie strony generuje komunikaty śledzenia, które mogą być dołączane do danych wyjściowych strony lub przechowywane w dzienniku śledzenia aplikacji. Aby wyświetlić zawartość dziennika śledzenia, możesz użyć przeglądarki śledzenia ASP.NET (Trace.axd).

Konstruktorów

Nazwa Opis
TraceSection()

Inicjuje TraceSection nowe wystąpienie klasy przy użyciu ustawień domyślnych.

Właściwości

Nazwa Opis
CurrentConfiguration

Pobiera odwołanie do wystąpienia najwyższego poziomu Configuration reprezentującego hierarchię konfiguracji, do którego należy bieżące ConfigurationElement wystąpienie.

(Dziedziczone od ConfigurationElement)
ElementInformation

ElementInformation Pobiera obiekt, który zawiera informacje i funkcje ConfigurationElement obiektu, które nie można dostosowywać.

(Dziedziczone od ConfigurationElement)
ElementProperty

ConfigurationElementProperty Pobiera obiekt reprezentujący ConfigurationElement sam obiekt.

(Dziedziczone od ConfigurationElement)
Enabled

Pobiera lub ustawia wartość wskazującą, czy usługa śledzenia ASP.NET jest włączona.

EvaluationContext

ContextInformation Pobiera obiekt dla ConfigurationElement obiektu.

(Dziedziczone od ConfigurationElement)
HasContext

Pobiera wartość wskazującą CurrentConfiguration , czy właściwość ma wartość null.

(Dziedziczone od ConfigurationElement)
Item[ConfigurationProperty]

Pobiera lub ustawia właściwość lub atrybut tego elementu konfiguracji.

(Dziedziczone od ConfigurationElement)
Item[String]

Pobiera lub ustawia właściwość, atrybut lub element podrzędny tego elementu konfiguracji.

(Dziedziczone od ConfigurationElement)
LocalOnly

Pobiera lub ustawia wartość wskazującą, czy przeglądarka śledzenia ASP.NET (Trace.axd) jest dostępna tylko dla żądań z serwera sieci Web hosta.

LockAllAttributesExcept

Pobiera kolekcję zablokowanych atrybutów.

(Dziedziczone od ConfigurationElement)
LockAllElementsExcept

Pobiera kolekcję zablokowanych elementów.

(Dziedziczone od ConfigurationElement)
LockAttributes

Pobiera kolekcję zablokowanych atrybutów.

(Dziedziczone od ConfigurationElement)
LockElements

Pobiera kolekcję zablokowanych elementów.

(Dziedziczone od ConfigurationElement)
LockItem

Pobiera lub ustawia wartość wskazującą, czy element jest zablokowany.

(Dziedziczone od ConfigurationElement)
MostRecent

Pobiera lub ustawia wartość wskazującą, czy najnowsze żądania są zawsze przechowywane na serwerze.

PageOutput

Pobiera lub ustawia wartość wskazującą, czy informacje śledzenia ASP.NET są dołączane do danych wyjściowych każdej strony.

Properties

Pobiera kolekcję właściwości.

(Dziedziczone od ConfigurationElement)
RequestLimit

Pobiera lub ustawia wartość wskazującą maksymalną liczbę żądań do aplikacji, dla której ASP.NET przechowuje informacje śledzenia.

SectionInformation

SectionInformation Pobiera obiekt, który zawiera informacje i funkcje ConfigurationSection obiektu, które nie można dostosowywać.

(Dziedziczone od ConfigurationSection)
TraceMode

Pobiera lub ustawia kolejność wyświetlania ASP.NET informacji śledzenia.

WriteToDiagnosticsTrace

Pobiera lub ustawia wartość wskazującą, czy komunikaty emitowane za pośrednictwem śledzenia strony są przekazywane do wystąpienia Trace klasy.

Metody

Nazwa Opis
DeserializeElement(XmlReader, Boolean)

Odczytuje kod XML z pliku konfiguracji.

(Dziedziczone od ConfigurationElement)
DeserializeSection(XmlReader)

Odczytuje kod XML z pliku konfiguracji.

(Dziedziczone od ConfigurationSection)
Equals(Object)

Porównuje bieżące ConfigurationElement wystąpienie z określonym obiektem.

(Dziedziczone od ConfigurationElement)
GetHashCode()

Pobiera unikatową wartość reprezentującą bieżące ConfigurationElement wystąpienie.

(Dziedziczone od ConfigurationElement)
GetRuntimeObject()

Zwraca obiekt niestandardowy, gdy zostanie zastąpiony w klasie pochodnej.

(Dziedziczone od ConfigurationSection)
GetTransformedAssemblyString(String)

Zwraca przekształconą wersję określonej nazwy zestawu.

(Dziedziczone od ConfigurationElement)
GetTransformedTypeString(String)

Zwraca przekształconą wersję określonej nazwy typu.

(Dziedziczone od ConfigurationElement)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Dziedziczone od Object)
Init()

ConfigurationElement Ustawia obiekt na stan początkowy.

(Dziedziczone od ConfigurationElement)
InitializeDefault()

Służy do inicjowania domyślnego zestawu wartości dla ConfigurationElement obiektu.

(Dziedziczone od ConfigurationElement)
IsModified()

Wskazuje, czy ten element konfiguracji został zmodyfikowany od czasu ostatniego zapisania lub załadowania podczas implementacji w klasie pochodnej.

(Dziedziczone od ConfigurationSection)
IsReadOnly()

Pobiera wartość wskazującą, czy ConfigurationElement obiekt jest tylko do odczytu.

(Dziedziczone od ConfigurationElement)
ListErrors(IList)

Dodaje błędy nieprawidłowej właściwości w tym ConfigurationElement obiekcie i we wszystkich podelementach do przekazanej listy.

(Dziedziczone od ConfigurationElement)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Dziedziczone od Object)
OnDeserializeUnrecognizedAttribute(String, String)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany atrybut.

(Dziedziczone od ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany element.

(Dziedziczone od ConfigurationElement)
OnRequiredPropertyNotFound(String)

Zgłasza wyjątek, gdy nie można odnaleźć wymaganej właściwości.

(Dziedziczone od ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Dziedziczone od ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływana przed serializacji.

(Dziedziczone od ConfigurationElement)
Reset(ConfigurationElement)

Resetuje stan ConfigurationElement wewnętrzny obiektu, w tym blokady i kolekcje właściwości.

(Dziedziczone od ConfigurationElement)
ResetModified()

Resetuje wartość IsModified() metody w false przypadku implementacji w klasie pochodnej.

(Dziedziczone od ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

Zapisuje zawartość tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Dziedziczone od ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

Tworzy ciąg XML zawierający nieskonwergentny widok ConfigurationSection obiektu jako pojedynczą sekcję do zapisu w pliku.

(Dziedziczone od ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

Zapisuje zewnętrzne tagi tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Dziedziczone od ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Ustawia właściwość na określoną wartość.

(Dziedziczone od ConfigurationElement)
SetReadOnly()

IsReadOnly() Ustawia właściwość dla ConfigurationElement obiektu i wszystkich podelementów.

(Dziedziczone od ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

Wskazuje, czy określony element powinien być serializowany, gdy hierarchia obiektów konfiguracji jest serializowana dla określonej wersji docelowej programu .NET Framework.

(Dziedziczone od ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

Wskazuje, czy określona właściwość powinna być serializowana, gdy hierarchia obiektów konfiguracji jest serializowana dla określonej wersji docelowej programu .NET Framework.

(Dziedziczone od ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

Wskazuje, czy bieżące ConfigurationSection wystąpienie powinno być serializowane, gdy hierarchia obiektów konfiguracji jest serializowana dla określonej wersji docelowej programu .NET Framework.

(Dziedziczone od ConfigurationSection)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Dziedziczone od Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Modyfikuje obiekt w ConfigurationElement celu usunięcia wszystkich wartości, które nie powinny być zapisywane.

(Dziedziczone od ConfigurationElement)

Dotyczy

Zobacz także