Forum Discussion

ErickTr's avatar
ErickTr
New Contributor
3 months ago

Is that posible to export Task Activity or Error Logs with business rule?

Hi Team,

I am wondering is that posible to export Error Logs or Task Activity with business rule? 
I know we can extract data from cubes or dimensions using BRApi methods, but is there a similar approach that allows us to export Error Logs or Task Activity? If so, what methods or steps are needed to achieve this?

  • Henning's avatar
    Henning
    Valued Contributor II

    Hi, I am not aware of an existing Api function that allows you to do that. If no one else knows one, you will have to pull the information from the corresponding tables and join them together.

    Alternatively, you can extract both from the Systems tab if that suffices:

    Solved: Extract_Data_System - OneStream Community (onestreamsoftware.com)

    Depending on what you want to do with it, one can e.g. load the XML into Excel to filter the information in there. 
    In Excel: Data >> Get Data >> From File >> From XML

  • VRoig's avatar
    VRoig
    New Contributor II

    Hi!

    You can do a query directly to the system database tables to get the information. They are called "ErrorLog" and "TaskActivity". Something like: Select * from ErrorLog.

    If you need some exemple let me know.

  • MarcusH's avatar
    MarcusH
    Contributor III

    The MarketPlace solution Admin Solution Tools (AST) has examples in Dashboard Extender (log by date, by user etc):

     

    ''' <summary>
    ''' Performs a SQL query to retrieve a Log Analysis based on a date range
    ''' </summary>
    ''' <param name="si"></param>
    ''' <param name="dateRange"></param>
    ''' <returns></returns>
    Private Function GetLogAnalysisByDate(ByVal si As SessionInfo, ByVal dateRange As Integer) As DataTable
        Try
            'Define the SQL Statement				
            Dim parameters As List(Of DbParamInfo) = New List(Of DbParamInfo) From {
                    New DbParamInfo("@dateRange", dateRange)
                    }
    
            Dim newSql As String = "
            DECLARE @LogAnalysisByDate TABLE (DaysOld VARCHAR(50), LogonCount BIGINT, ErrorCount BIGINT, TaskCount BIGINT)
            -- Set the interval in days
            DECLARE @DateInterval INT = @dateRange
            --DECLARE @DaysOld INT = @DateInterval
            DECLARE @CurrentDate DATETIME = GETUTCDATE()
            --Set start date to number of days behind current date
            DECLARE @StartDate DATETIME = DATEADD(d, (@DateInterval) * -1, GETUTCDATE())
            DECLARE @EndDate DATETIME = GETUTCDATE()
            DECLARE @TotalLogs BIGINT = (SELECT ((SELECT COUNT(*) FROM UserLogonActivity)+(SELECT COUNT(*) FROM ErrorLog)+(SELECT COUNT(*) FROM TaskActivity)))	
            DECLARE @Loop INT = 0
            DECLARE @DaysFrom INT = 0
            DECLARE @DaysTo INT = @DateInterval
            DECLARE @LogonCount INT 
            DECLARE @ErrorCount INT 
            DECLARE @TaskActivityCount INT 
    
            WHILE (SELECT ISNULL(SUM(LogonCount) + SUM(ErrorCount) + SUM(TaskCount), 0) FROM @LogAnalysisByDate) < @TotalLogs	
                BEGIN 			
                    SET @LogonCount = (SELECT COUNT(*) FROM UserLogonActivity WHERE LogonTime BETWEEN @StartDate AND @EndDate) 
                    SET @ErrorCount = (SELECT COUNT(*) FROM ErrorLog WHERE ErrorTime BETWEEN @StartDate AND @EndDate) 
                    SET @TaskActivityCount = (SELECT COUNT(*) FROM TaskActivity WHERE QueuedTime BETWEEN @StartDate AND @EndDate) 		
                    IF @Loop > 0 
                        BEGIN
                            -- Set the DaysOld column value
                            SET @DaysTo = @DaysTo + @DateInterval
                            SET @DaysFrom = @DaysTo - @DateInterval + 1					
                        END				
    
                    -- Update the start and end dates
                    SET @EndDate = @StartDate 
                    SET @StartDate = DATEADD(d, (@DaysTo + @DateInterval) * -1, GETUTCDATE());
    
                    -- Insert the row
                    INSERT INTO @LogAnalysisByDate 
                    SELECT (CONVERT(VARCHAR(50), @DaysFrom) + ' - ' + CONVERT(VARCHAR(50), @DaysTo)), @LogonCount, @ErrorCount, @TaskActivityCount 		
                    -- Increment the loop count
                    SET @Loop = @Loop + 1
                    
                END 
    
                SELECT * FROM @LogAnalysisByDate "					
    
            'Return the DataTable
            Using DbConnFW As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
                Return BRApi.Database.ExecuteSql(DbConnFW, newSql, parameters, False)
            End Using
    
        Catch ex As Exception
            Throw ErrorHandler.LogWrite(si, New XFException(si, "Unhandled Exception in GetLogAnalysisByDate() function.", ex.Message, ex.InnerException))
        End Try
    End Function