How to use Server.CaptureLog in SSAS

Mina Kamel 101 Reputation points
2021-01-05T13:49:01.09+00:00

Hello,

i'm new to SSAS I'm trying to create a PS script to process cubes level 1500 and be able to capture all the details of the processing into a log file. is it possible to do so?

thanks a lot for all the help in advance.

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,243 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,361 questions
0 comments No comments
{count} votes

Accepted answer
  1. Darren Gosbell 1,466 Reputation points
    2021-01-12T08:48:20.16+00:00

    The CaptureLog is an old multi-dimensional interface and it was not used for capturing processing messages.

    The output you see when running a json refresh command come from the SessionTrace events. The following is a short script showing how you can subscribe to the processing events and send it to the console with a Write-Host command - you should be able to alter this without too much trouble to send the output to a log file (or you could just redirect the console output to a file)

    $serverName = "localhost\tab17"
    $databaseName = "Adventure Works"
    
    # load the TOM library
    $ass = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")
    
    # declare the trace event handler
    $handler_OnTraceEvent =
    {
        param([object]$sender, [Microsoft.AnalysisServices.Tabular.TraceEventArgs]$e)
        write-host  "$($e.EventClass) - $($e.EventSubclass) - $($e.TextData)"
    }
    
    # connect to the server
    $server = [Microsoft.AnalysisServices.Tabular.Server]::new()
    $server.Connect($serverName)
    $trace = $server.SessionTrace
    
    Register-ObjectEvent -InputObject $trace -EventName OnEvent -Action $handler_OnTraceEvent
    
    $trace.Start()
    
    # wait 5 seconds to let the trace start up
    start-sleep -seconds 5
    
    $db = $server.Databases.GetByName("Adventure Works")
    $db.Model.RequestRefresh([Microsoft.AnalysisServices.Tabular.RefreshType]::Full)
    $res = $db.Model.SaveChanges()
    # output the results of the refresh operation (in case there are any errors)
    $res.XmlaResults
    
    #stop the trace and output the lastProcessed date for the database
    $trace.Stop()
    $db.refresh()
    $db.LastProcessed
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Lukas Yu -MSFT 5,816 Reputation points
    2021-01-06T07:18:39.697+00:00

    Hi,

    PS script to process cubes level 1500

    I guess you want to using PowerShell script to call the SSAS server to process a Tabular Database. Right?

    For this you could generate the database processing XMLA script, and the using Invoke-ASCmd to run this processing script in powershell. You could see detail description in the article : PowerShell Commands for SQL Server Analysis Services Tabular Mode - Create a Script from SSMS to Process a Database with PowerShell

    There is no direct log or logging tool in SSAS, but similarly you could use XMLA script for Extended Events to log what's going on in the server . Introduction To Analysis Services Extended Events

    Combine these two should work for this scene.

    Regards,
    Lukas


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    What can I do if my transaction log is full?--- Hot issues November
    How to convert Profiler trace into a SQL Server table -- Hot issues November