TraceSection Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mengonfigurasi layanan pelacakan ASP.NET. Kelas ini tidak dapat diwariskan.
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
- Warisan
Contoh
Contoh kode berikut menunjukkan cara menggunakan jenis .TraceSection
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
Keterangan
Kelas ini TraceSection menyediakan cara untuk mengakses dan memodifikasi konten bagian file trace konfigurasi secara terprogram. Bagian trace mengonfigurasi fungsionalitas pelacakan ASP.NET dan mengontrol bagaimana hasil jejak dikumpulkan, disimpan, dan ditampilkan.
Saat pelacakan diaktifkan, setiap permintaan halaman menghasilkan pesan pelacakan yang dapat ditambahkan ke output halaman atau disimpan dalam log pelacakan aplikasi. Anda dapat menggunakan penampil jejak ASP.NET (Trace.axd) untuk melihat konten log jejak.
Konstruktor
| Nama | Deskripsi |
|---|---|
| TraceSection() |
Menginisialisasi instans TraceSection baru kelas menggunakan pengaturan default. |
Properti
| Nama | Deskripsi |
|---|---|
| CurrentConfiguration |
Mendapatkan referensi ke instans Configuration tingkat atas yang mewakili hierarki konfigurasi tempat instans ConfigurationElement saat ini berada. (Diperoleh dari ConfigurationElement) |
| ElementInformation |
Mendapatkan objek ElementInformation yang berisi informasi dan fungsionalitas yang tidak dapat disesuaikan dari objek ConfigurationElement. (Diperoleh dari ConfigurationElement) |
| ElementProperty |
Mendapatkan objek ConfigurationElementProperty yang mewakili objek ConfigurationElement itu sendiri. (Diperoleh dari ConfigurationElement) |
| Enabled |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah layanan pelacakan ASP.NET diaktifkan. |
| EvaluationContext |
Mendapatkan objek ContextInformation untuk objek ConfigurationElement. (Diperoleh dari ConfigurationElement) |
| HasContext |
Mendapatkan nilai yang menunjukkan apakah properti CurrentConfiguration |
| Item[ConfigurationProperty] |
Mendapatkan atau mengatur properti atau atribut elemen konfigurasi ini. (Diperoleh dari ConfigurationElement) |
| Item[String] |
Mendapatkan atau mengatur properti, atribut, atau elemen turunan dari elemen konfigurasi ini. (Diperoleh dari ConfigurationElement) |
| LocalOnly |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah penampil jejak ASP.NET (Trace.axd) hanya tersedia untuk permintaan dari server Web host. |
| LockAllAttributesExcept |
Mendapatkan koleksi atribut terkunci. (Diperoleh dari ConfigurationElement) |
| LockAllElementsExcept |
Mendapatkan koleksi elemen terkunci. (Diperoleh dari ConfigurationElement) |
| LockAttributes |
Mendapatkan koleksi atribut terkunci. (Diperoleh dari ConfigurationElement) |
| LockElements |
Mendapatkan koleksi elemen terkunci. (Diperoleh dari ConfigurationElement) |
| LockItem |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah elemen dikunci. (Diperoleh dari ConfigurationElement) |
| MostRecent |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah permintaan terbaru selalu disimpan di server. |
| PageOutput |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah informasi jejak ASP.NET ditambahkan ke output setiap halaman. |
| Properties |
Mendapatkan koleksi properti. (Diperoleh dari ConfigurationElement) |
| RequestLimit |
Mendapatkan atau menetapkan nilai yang menunjukkan jumlah maksimum permintaan ke aplikasi yang ASP.NET menyimpan informasi pelacakan. |
| SectionInformation |
Mendapatkan objek SectionInformation yang berisi informasi dan fungsionalitas yang tidak dapat disesuaikan dari objek ConfigurationSection. (Diperoleh dari ConfigurationSection) |
| TraceMode |
Mendapatkan atau mengatur urutan ASP.NET informasi pelacakan ditampilkan. |
| WriteToDiagnosticsTrace |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah pesan yang dipancarkan melalui jejak halaman diteruskan ke instans Trace kelas. |
Metode
| Nama | Deskripsi |
|---|---|
| DeserializeElement(XmlReader, Boolean) |
Membaca XML dari file konfigurasi. (Diperoleh dari ConfigurationElement) |
| DeserializeSection(XmlReader) |
Membaca XML dari file konfigurasi. (Diperoleh dari ConfigurationSection) |
| Equals(Object) |
Membandingkan instans ConfigurationElement saat ini dengan objek yang ditentukan. (Diperoleh dari ConfigurationElement) |
| GetHashCode() |
Mendapatkan nilai unik yang mewakili instans ConfigurationElement saat ini. (Diperoleh dari ConfigurationElement) |
| GetRuntimeObject() |
Mengembalikan objek kustom saat ditimpa di kelas turunan. (Diperoleh dari ConfigurationSection) |
| GetTransformedAssemblyString(String) |
Mengembalikan versi yang diubah dari nama rakitan yang ditentukan. (Diperoleh dari ConfigurationElement) |
| GetTransformedTypeString(String) |
Mengembalikan versi yang diubah dari nama jenis yang ditentukan. (Diperoleh dari ConfigurationElement) |
| GetType() |
Mendapatkan Type instans saat ini. (Diperoleh dari Object) |
| Init() |
Mengatur objek ConfigurationElement ke status awalnya. (Diperoleh dari ConfigurationElement) |
| InitializeDefault() |
Digunakan untuk menginisialisasi sekumpulan nilai default untuk objek ConfigurationElement. (Diperoleh dari ConfigurationElement) |
| IsModified() |
Menunjukkan apakah elemen konfigurasi ini telah dimodifikasi sejak terakhir disimpan atau dimuat saat diimplementasikan di kelas turunan. (Diperoleh dari ConfigurationSection) |
| IsReadOnly() |
Mendapatkan nilai yang menunjukkan apakah objek ConfigurationElement bersifat baca-saja. (Diperoleh dari ConfigurationElement) |
| ListErrors(IList) |
Menambahkan kesalahan properti yang tidak valid dalam objek ConfigurationElement ini, dan di semua subelemen, ke daftar yang diteruskan. (Diperoleh dari ConfigurationElement) |
| MemberwiseClone() |
Membuat salinan dangkal dari Objectsaat ini. (Diperoleh dari Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Mendapatkan nilai yang menunjukkan apakah atribut yang tidak diketahui ditemui selama deserialisasi. (Diperoleh dari ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Mendapatkan nilai yang menunjukkan apakah elemen yang tidak diketahui ditemui selama deserialisasi. (Diperoleh dari ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Melempar pengecualian ketika properti yang diperlukan tidak ditemukan. (Diperoleh dari ConfigurationElement) |
| PostDeserialize() |
Dipanggil setelah deserialisasi. (Diperoleh dari ConfigurationElement) |
| PreSerialize(XmlWriter) |
Dipanggil sebelum serialisasi. (Diperoleh dari ConfigurationElement) |
| Reset(ConfigurationElement) |
Mereset status internal objek ConfigurationElement, termasuk kunci dan koleksi properti. (Diperoleh dari ConfigurationElement) |
| ResetModified() |
Mengatur ulang nilai metode IsModified() ke |
| SerializeElement(XmlWriter, Boolean) |
Menulis konten elemen konfigurasi ini ke file konfigurasi saat diimplementasikan di kelas turunan. (Diperoleh dari ConfigurationElement) |
| SerializeSection(ConfigurationElement, String, ConfigurationSaveMode) |
Membuat string XML yang berisi tampilan objek ConfigurationSection yang tidak digabungkan sebagai satu bagian untuk ditulis ke file. (Diperoleh dari ConfigurationSection) |
| SerializeToXmlElement(XmlWriter, String) |
Menulis tag luar elemen konfigurasi ini ke file konfigurasi saat diimplementasikan di kelas turunan. (Diperoleh dari ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Mengatur properti ke nilai yang ditentukan. (Diperoleh dari ConfigurationElement) |
| SetReadOnly() |
Mengatur properti IsReadOnly() untuk objek ConfigurationElement dan semua subelemen. (Diperoleh dari ConfigurationElement) |
| ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) |
Menunjukkan apakah elemen yang ditentukan harus diserialisasikan ketika hierarki objek konfigurasi diserialisasikan untuk versi target yang ditentukan dari .NET Framework. (Diperoleh dari ConfigurationSection) |
| ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement) |
Menunjukkan apakah properti yang ditentukan harus diserialisasikan ketika hierarki objek konfigurasi diserialisasikan untuk versi target yang ditentukan dari .NET Framework. (Diperoleh dari ConfigurationSection) |
| ShouldSerializeSectionInTargetVersion(FrameworkName) |
Menunjukkan apakah instans ConfigurationSection saat ini harus diserialisasikan ketika hierarki objek konfigurasi diserialisasikan untuk versi target yang ditentukan dari .NET Framework. (Diperoleh dari ConfigurationSection) |
| ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Memodifikasi objek ConfigurationElement untuk menghapus semua nilai yang tidak boleh disimpan. (Diperoleh dari ConfigurationElement) |