How to: Use the Activity Log
VSPackages can write messages to the activity log. This feature is especially useful for debugging VSPackages in retail environments.
Tip
|
|---|
|
The activity log is always turned on. Visual Studio keeps a rolling buffer of the last one hundred entries as well as the first ten entries, which have general configuration information. |
To write an entry to the activity log
-
Insert this code in the Initialize method or in any other method except the VSPackage constructor:
Dim log As IVsActivityLog = _ TryCast(Me.GetService(GetType(SVsActivityLog)), IVsActivityLog) If (log Is Nothing) Then Return Dim hr As Integer = log.LogEntry( _ CUInt(__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION), _ Me.ToString(), _ String.Format(CultureInfo.CurrentCulture, _ "Entering initializer for: {0}", Me.ToString()))
This code gets the SVsActivityLog service and casts it to an IVsActivityLog interface. LogEntry writes an informational entry into the activity log using the current cultural context.
-
Load the VSPackage.
To examine the activity log
-
Find the activity log in the subfolder for Visual Studio data.
For example, %AppData%\Microsoft\VisualStudio\11.0\ActivityLog.XML.
-
Open the activity log with any text editor.
Following is a typical entry:
50 Entering initializer for: Company.MyApp.MyAppPackage ...
Tip