<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Extracting Error message from Qlik Log files for respective APP IDs in data load editor. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Extracting-Error-message-from-Qlik-Log-files-for-respective-APP/m-p/1958094#M78993</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;Hope all are doing well!.&lt;/P&gt;
&lt;P&gt;Friends I need some help/suggestion on below requirements.&lt;/P&gt;
&lt;P&gt;1.I have a one Service Scheduler Log file where it contains all APP ID's which were failed during Execution (See Attachment 1) from where I have to consider those all APP ID's and need to pick those Log files.&lt;/P&gt;
&lt;P&gt;2. In log files folder(See Attachment) both failed and successfully executed files present.(But Only Failed files need to be consider) having same APP id's from Log folder where all log files are stored after execution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Then I need to find out the Error message from those respective APP Id's&amp;nbsp; after the failed execution and need to send those Error message.&lt;/P&gt;
&lt;P&gt;4. Also I need&amp;nbsp; latest log files only from log folder and the same APP ID must be present in Service schedule file.&lt;/P&gt;
&lt;P&gt;5. The following Code I am using but I am missing somewhere. Please guide me on this.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Script to Read from Service scheduler file&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Service_Scheduler:&lt;BR /&gt;LOAD&lt;BR /&gt;// Sequence#,&lt;BR /&gt;// "ProductVersion",&lt;BR /&gt;"Timestamp",&lt;BR /&gt;// Severity,&lt;BR /&gt;// Hostname,&lt;BR /&gt;Id,&lt;BR /&gt;// Description,&lt;BR /&gt;// ProxySessionId,&lt;BR /&gt;// ProxyPackageId,&lt;BR /&gt;// RequestSequenceId,&lt;BR /&gt;UserDirectory,&lt;BR /&gt;"UserId",&lt;BR /&gt;ObjectId,&lt;BR /&gt;SubField(ObjectId, '|',2) As AppID,&lt;BR /&gt;// FileTime() As FileDate,&lt;BR /&gt;timestamp#(left(Timestamp,18), 'DD-MM-YYYY hh:mm:ss') as Timestamp_Script_SS,&lt;BR /&gt;ObjectName,&lt;BR /&gt;// Service,&lt;BR /&gt;// Origin,&lt;BR /&gt;// Context,&lt;BR /&gt;// Command,&lt;BR /&gt;// Result,&lt;BR /&gt;Message,&lt;BR /&gt;Id2&lt;BR /&gt;FROM [lib://FLDR_Qlik_System_Scheduler_Log/A11W2V1351_Service_Scheduler.txt]&lt;BR /&gt;(txt, utf8, embedded labels, delimiter is '\t', msq);&lt;/P&gt;
&lt;P&gt;Let vNumberOfRows = NoOfRows('Service_Scheduler');&lt;/P&gt;
&lt;P&gt;For x=0 to $(vNumberOfRows)-1&lt;BR /&gt;Let vAppID = Peek('AppID', $(x), 'Service_Scheduler');&lt;BR /&gt;Let vTimestamp = Peek('Timestamp', $(x), 'Service_Scheduler');&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Script to Read Log Files from Log Folder&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;LogFiles:&lt;BR /&gt;LOAD&lt;BR /&gt;FileName() As FileName&lt;BR /&gt;, timestamp#(Mid(FileName(),37,18), 'DD-MM-YYYY hh:mm:ss') as Timestamp_Script_LogFile&lt;BR /&gt;, FileTime() As FileDate&lt;BR /&gt;, Left(FileName(),36) As LogFiles_AppID&lt;BR /&gt;, RowNo() As RowNumber&lt;BR /&gt;, @1 As LogScript&lt;BR /&gt;, Right([@1], Len([@1]) - Index([@1], ' ', 1)) as LogScriptText&lt;BR /&gt;FROM [lib://FLDR_Qlik_ArchivedLogs_Script/*2022*.log](txt, utf8, no labels, delimiter is '\n', no quotes, no eof)&lt;BR /&gt;where Floor(FileTime())= $(vToday)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//Add the last row number&lt;BR /&gt;Left Join(LogFiles)&lt;BR /&gt;Load&lt;BR /&gt;FileName //Joined field&lt;BR /&gt;, Max(RowNumber) As LastRowNumber&lt;BR /&gt;Resident LogFiles&lt;BR /&gt;Group By FileName&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//Get the execution result from the last 2 lines of the log script&lt;BR /&gt;Left Join(LogFiles)&lt;BR /&gt;Load&lt;BR /&gt;FileName //Joined field&lt;BR /&gt;, Lower( SubField( Subfield( Concat(LogScript, '.') //Combine the last 2 rows&lt;BR /&gt;, 'Execution ', 2 //Keep the text after the word "Execution "&lt;BR /&gt;)&lt;BR /&gt;, '.', 1 //Keep the text before the dot&lt;BR /&gt;)&lt;BR /&gt;) As ExecutionResult&lt;BR /&gt;Resident LogFiles&lt;BR /&gt;Where RowNumber &amp;gt; LastRowNumber - 2 //Get the last 2 rows&lt;BR /&gt;Group By FileName&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;Temp:&lt;BR /&gt;Load *,&lt;BR /&gt;If(ExecutionResult='failed', ExecutionResult) as ExecutionResult_Failed&lt;BR /&gt;//ExecutionResult&lt;BR /&gt;Resident LogFiles&lt;BR /&gt;where ExecutionResult='failed'&lt;BR /&gt;AND WildMatch(LogScriptText,'*Error: *');&lt;/P&gt;
&lt;P&gt;Drop Tables LogFiles;&lt;/P&gt;
&lt;P&gt;Let vNumberOfErrorRows = NoOfRows('Temp');&lt;/P&gt;
&lt;P&gt;For x=0 to $(vNumberOfErrorRows)-1&lt;BR /&gt;Let vAppID1 = Peek('LogFiles_AppID', $(x), 'Temp');&lt;BR /&gt;Let vErrorText = Peek('LogScriptText', $(x), 'Temp');&lt;BR /&gt;Next&lt;/P&gt;
&lt;P&gt;Rename table Temp to LogFiles;&lt;/P&gt;
&lt;P&gt;Exit Script;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above code considers all logfile and then it is filtering the files whenever it getting "Error:" as matching string,&lt;/P&gt;
&lt;P&gt;I am getting the following output as attached.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2022 08:14:51 GMT</pubDate>
    <dc:creator>sanjaya9203</dc:creator>
    <dc:date>2022-07-20T08:14:51Z</dc:date>
    <item>
      <title>Extracting Error message from Qlik Log files for respective APP IDs in data load editor.</title>
      <link>https://community.qlik.com/t5/App-Development/Extracting-Error-message-from-Qlik-Log-files-for-respective-APP/m-p/1958094#M78993</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;Hope all are doing well!.&lt;/P&gt;
&lt;P&gt;Friends I need some help/suggestion on below requirements.&lt;/P&gt;
&lt;P&gt;1.I have a one Service Scheduler Log file where it contains all APP ID's which were failed during Execution (See Attachment 1) from where I have to consider those all APP ID's and need to pick those Log files.&lt;/P&gt;
&lt;P&gt;2. In log files folder(See Attachment) both failed and successfully executed files present.(But Only Failed files need to be consider) having same APP id's from Log folder where all log files are stored after execution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Then I need to find out the Error message from those respective APP Id's&amp;nbsp; after the failed execution and need to send those Error message.&lt;/P&gt;
&lt;P&gt;4. Also I need&amp;nbsp; latest log files only from log folder and the same APP ID must be present in Service schedule file.&lt;/P&gt;
&lt;P&gt;5. The following Code I am using but I am missing somewhere. Please guide me on this.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Script to Read from Service scheduler file&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Service_Scheduler:&lt;BR /&gt;LOAD&lt;BR /&gt;// Sequence#,&lt;BR /&gt;// "ProductVersion",&lt;BR /&gt;"Timestamp",&lt;BR /&gt;// Severity,&lt;BR /&gt;// Hostname,&lt;BR /&gt;Id,&lt;BR /&gt;// Description,&lt;BR /&gt;// ProxySessionId,&lt;BR /&gt;// ProxyPackageId,&lt;BR /&gt;// RequestSequenceId,&lt;BR /&gt;UserDirectory,&lt;BR /&gt;"UserId",&lt;BR /&gt;ObjectId,&lt;BR /&gt;SubField(ObjectId, '|',2) As AppID,&lt;BR /&gt;// FileTime() As FileDate,&lt;BR /&gt;timestamp#(left(Timestamp,18), 'DD-MM-YYYY hh:mm:ss') as Timestamp_Script_SS,&lt;BR /&gt;ObjectName,&lt;BR /&gt;// Service,&lt;BR /&gt;// Origin,&lt;BR /&gt;// Context,&lt;BR /&gt;// Command,&lt;BR /&gt;// Result,&lt;BR /&gt;Message,&lt;BR /&gt;Id2&lt;BR /&gt;FROM [lib://FLDR_Qlik_System_Scheduler_Log/A11W2V1351_Service_Scheduler.txt]&lt;BR /&gt;(txt, utf8, embedded labels, delimiter is '\t', msq);&lt;/P&gt;
&lt;P&gt;Let vNumberOfRows = NoOfRows('Service_Scheduler');&lt;/P&gt;
&lt;P&gt;For x=0 to $(vNumberOfRows)-1&lt;BR /&gt;Let vAppID = Peek('AppID', $(x), 'Service_Scheduler');&lt;BR /&gt;Let vTimestamp = Peek('Timestamp', $(x), 'Service_Scheduler');&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Script to Read Log Files from Log Folder&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;LogFiles:&lt;BR /&gt;LOAD&lt;BR /&gt;FileName() As FileName&lt;BR /&gt;, timestamp#(Mid(FileName(),37,18), 'DD-MM-YYYY hh:mm:ss') as Timestamp_Script_LogFile&lt;BR /&gt;, FileTime() As FileDate&lt;BR /&gt;, Left(FileName(),36) As LogFiles_AppID&lt;BR /&gt;, RowNo() As RowNumber&lt;BR /&gt;, @1 As LogScript&lt;BR /&gt;, Right([@1], Len([@1]) - Index([@1], ' ', 1)) as LogScriptText&lt;BR /&gt;FROM [lib://FLDR_Qlik_ArchivedLogs_Script/*2022*.log](txt, utf8, no labels, delimiter is '\n', no quotes, no eof)&lt;BR /&gt;where Floor(FileTime())= $(vToday)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//Add the last row number&lt;BR /&gt;Left Join(LogFiles)&lt;BR /&gt;Load&lt;BR /&gt;FileName //Joined field&lt;BR /&gt;, Max(RowNumber) As LastRowNumber&lt;BR /&gt;Resident LogFiles&lt;BR /&gt;Group By FileName&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//Get the execution result from the last 2 lines of the log script&lt;BR /&gt;Left Join(LogFiles)&lt;BR /&gt;Load&lt;BR /&gt;FileName //Joined field&lt;BR /&gt;, Lower( SubField( Subfield( Concat(LogScript, '.') //Combine the last 2 rows&lt;BR /&gt;, 'Execution ', 2 //Keep the text after the word "Execution "&lt;BR /&gt;)&lt;BR /&gt;, '.', 1 //Keep the text before the dot&lt;BR /&gt;)&lt;BR /&gt;) As ExecutionResult&lt;BR /&gt;Resident LogFiles&lt;BR /&gt;Where RowNumber &amp;gt; LastRowNumber - 2 //Get the last 2 rows&lt;BR /&gt;Group By FileName&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;Temp:&lt;BR /&gt;Load *,&lt;BR /&gt;If(ExecutionResult='failed', ExecutionResult) as ExecutionResult_Failed&lt;BR /&gt;//ExecutionResult&lt;BR /&gt;Resident LogFiles&lt;BR /&gt;where ExecutionResult='failed'&lt;BR /&gt;AND WildMatch(LogScriptText,'*Error: *');&lt;/P&gt;
&lt;P&gt;Drop Tables LogFiles;&lt;/P&gt;
&lt;P&gt;Let vNumberOfErrorRows = NoOfRows('Temp');&lt;/P&gt;
&lt;P&gt;For x=0 to $(vNumberOfErrorRows)-1&lt;BR /&gt;Let vAppID1 = Peek('LogFiles_AppID', $(x), 'Temp');&lt;BR /&gt;Let vErrorText = Peek('LogScriptText', $(x), 'Temp');&lt;BR /&gt;Next&lt;/P&gt;
&lt;P&gt;Rename table Temp to LogFiles;&lt;/P&gt;
&lt;P&gt;Exit Script;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above code considers all logfile and then it is filtering the files whenever it getting "Error:" as matching string,&lt;/P&gt;
&lt;P&gt;I am getting the following output as attached.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 08:14:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Extracting-Error-message-from-Qlik-Log-files-for-respective-APP/m-p/1958094#M78993</guid>
      <dc:creator>sanjaya9203</dc:creator>
      <dc:date>2022-07-20T08:14:51Z</dc:date>
    </item>
  </channel>
</rss>

