Jaa


Readme for ASTrace Utility Sample

The ASTrace utility provides you with ability to capture an Analysis Services trace and log it into a SQL Server table. The table can be queried later or read using SQL Server Profiler. The ASTrace utility runs as a Windows service that connects to Analysis Services, then creates a trace, and logs trace events into a SQL Server table using the SQL Server Profiler format. The ASTrace utility creates the trace using a standard trace template that you can author using SQL Server Profiler.

Scenario

Analysis Services does not have a built-in tool to extract traces and save them to a file or table. This ASTrace utility sample demonstrates how to implement that trace functionality.

Languages

C#

Prerequisites

Before running this sample, make sure the following software is installed:

  • Microsoft SQL Server 2005, including the following components:
    • Database Engine
    • Analysis Services
    • SQL Server Management Studio
    • Business Intelligence Development Studio
    • Database Engine Samples
  • Microsoft.NET Framework SDK 2.0 or Visual Studio 2005

Building the Sample

Option 1: To build the sample by using Visual Studio

  1. Locate the folder where the solution file ASTrace.sln is stored.

  2. Move the signature file ASTrace.snk to the solution folder.

  3. Open Visual Studio.

  4. On the Recent Projects tab, for Open, click Project.

  5. Open the folder where you saved the solution file ASTrace.sln, select the file, and then click Open.

  6. Press F6 to build the project.

Option 2: To build the sample by using msbuild.exe from .Net Framework SDK

  1. Locate the folder where the solution file ASTrace.sln is stored.

  2. Move the signature file ASTracer.snk to the solution folder.

  3. Open a Command Prompt window and change directory to the location where the solution file is saved. Configure the environment according to the specifications in the .NET Framework Developer's Guide topic, How to: Compile at the Command Prompt.

  4. Type msbuild.exe ASTrace.sln, then press Enter.

Installing the Sample

The following procedures describe how to install the ASTrace utility as a service.

Step 1: To copy executable files

  • Copy the following files into the folder where you intend to have the service running on your computer:

    • ASTrace.exe
    • ASTrace.exe.config
    • Standard.tdf

Step 2: To register the service

  1. Locate InstallUtil.exe in your installed version of the Microsoft .NET Framework SDK 2.0.

  2. Open a Command Prompt window.

  3. Change the current directory to the directory where you copied the executables files in previous step.

  4. Add the folder that contains InstallUtil.exe to the path.

  5. Run the following command to install the service:

    InstallUtil.exe ASTrace.exe

  6. In Administrative Tools, open Computer Management, expand Services and Applications, and then select Services.

  7. Search for ASTrace Service in the right pane and double-click it. Verify in the General tab that the Path to executable shows the correct path to where you copied the files. The service is now registered and using your files.

    Note

    Do not start the service until is configured in the next step.

Step 3: To configure the service

  1. Open the ASTrace.exe.config file in Notepad or any other text editor that does not include control characters.

  2. Add content to the following fields according to their definition:

    • AnalysisServerName—the name of the instance of Analysis Service to trace.
    • SQLServer—Name of the SQL Server instance where the trace will be logged.
    • SQLServerDatabase—the name of the SQL Server database that will hold the trace tables.
    • TraceTableName—the name of the table to log the trace into.
    • TraceDefinition—the name of the file containing the trace template you used to create the Analysis Services trace. If you need to your modify ASTrace template, do so by using SQL Server Profiler.

Running the Sample

The following procedures show how to start the service and configure security.

Step 1: To start the service

  • Open Windows Service Control Manager, navigate to the ASTrace utility and start the service.

    If the service starts successfully, it means it was able to connect to an instance of Analysis Services and create a trace; also, it was able to connect to SQL Server and create a trace table and started logging to it.

    If any problems occur during startup, you will see the error logged into ASTraceService.log file created in your local installation directory. Check the names again make sure all server names specified correctly and the ASTrace service has appropriate security permissions. The ASTrace utility is installed using LocalSystem account to give you the ability to test its functionality.

Step 2: To configure security

  1. Make sure you change the ASTrace service account to an appropriate local or domain user account. This will minimize the surface attack area.

  2. To run the ASTrace service application, you must make sure that the service account that runs the service has following rights:

    • Analysis Services administrator permission.
    • SQL Server database administrator rights to create a table in the database you specified and log events.

Removing the Sample

Use the following procedure to uninstall the service.

To uninstall the ASTrace service

  • Open a Command Prompt window and run the following command:

    InstallUtil.exe ASTrace.exe