AspLog 类

定义

提供用于将事件和异常信息写入应用程序的日志侦听器中的属性和方法。Provides a property and methods for writing event and exception information to the application's log listeners.

public ref class AspLog : Microsoft::VisualBasic::Logging::Log
public class AspLog : Microsoft.VisualBasic.Logging.Log
type AspLog = class
    inherit Log
Public Class AspLog
Inherits Log
继承
AspLog

示例

本示例将演示如何使用 My.Application.Log.WriteEntry 方法来记录跟踪信息。This example shows how to use the My.Application.Log.WriteEntry method to log tracing information. 有关详细信息,请参阅 如何:编写日志消息For more information, see How to: Write Log Messages.

Public Sub TracingTest(ByVal fileName As String)
    My.Application.Log.WriteEntry( 
        "Entering TracingTest with argument " & 
        fileName & ".")
    ' Code to trace goes here.
    My.Application.Log.WriteEntry( 
        "Exiting TracingTest with argument " & 
        fileName & ".")
End Sub

注解

My.Application.Log对象提供了一个简单的入口点,用于访问 .NET Framework.NET Framework 的日志记录服务。The My.Application.Log object provides a straightforward entry point from which to access the .NET Framework.NET Framework's logging services. WriteEntryWriteException 方法将消息写入应用程序的日志侦听器。The WriteEntry and WriteException methods write messages to the application's log listeners. 可以通过应用程序的配置文件来配置侦听器。The listeners can be configured by the application's configuration file. 有关详细信息,请参阅 演练:更改 My. Log 写入信息 和使用 应用程序日志的位置。For more information, see Walkthrough: Changing Where My.Application.Log Writes Information and Working with Application Logs.

My.Application.Log对象仅适用于客户端应用程序。The My.Application.Log object is available only for client applications. 对于 Web 应用程序,请使用 My.LogFor Web applications, use My.Log. 有关详细信息,请参阅 Microsoft.VisualBasic.Logging.LogFor more information, see Microsoft.VisualBasic.Logging.Log.

下表列出了涉及对象的任务的示例 My.Application.LogThe following table lists examples of tasks involving the My.Application.Log object.

功能To 查看See
将事件信息写入应用程序的日志侦听器Write event information to the application's log listeners 如何:写入日志消息How to: Write Log Messages
将异常信息写入应用程序的日志侦听器Write exception information to the application's log listeners 如何:日志异常How to: Log Exceptions
确定 My.Application.Log 写入信息的位置Determine where My.Application.Log writes information 演练:确定 My.Application.Log 在哪里写入信息Walkthrough: Determining Where My.Application.Log Writes Information

构造函数

AspLog()

初始化 AspLog 类的新实例。Initializes a new instance of the AspLog class.

AspLog(String)

初始化 AspLog 类的新实例。Initializes a new instance of the AspLog class.

属性

DefaultFileLogWriter

获取为 Log 对象提供支持的 FileLogTraceListener 对象。Gets the file the FileLogTraceListener object that underlies the Log object.

(继承自 Log)
TraceSource

获取为 Log 对象提供支持的 TraceSource 对象。Gets to the TraceSource object that underlies the Log object.

(继承自 Log)

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeWithDefaultsSinceNoConfigExists()

创建一个新的 FileLogTraceListener,然后将它添加到 Listeners 集合中。Creates a new FileLogTraceListener and adds it to the Listeners collection.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
WriteEntry(String)

将消息写入应用程序的日志侦听器中。Writes a message to the application's log listeners.

(继承自 Log)
WriteEntry(String, TraceEventType)

将消息写入应用程序的日志侦听器中。Writes a message to the application's log listeners.

(继承自 Log)
WriteEntry(String, TraceEventType, Int32)

将消息写入应用程序的日志侦听器中。Writes a message to the application's log listeners.

(继承自 Log)
WriteException(Exception)

将异常信息写入应用程序的日志侦听器中。Writes exception information to the application's log listeners.

(继承自 Log)
WriteException(Exception, TraceEventType, String)

将异常信息写入应用程序的日志侦听器中。Writes exception information to the application's log listeners.

(继承自 Log)
WriteException(Exception, TraceEventType, String, Int32)

将异常信息写入应用程序的日志侦听器中。Writes exception information to the application's log listeners.

(继承自 Log)

适用于

另请参阅