Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rohitk1609
Master
Master

How to auto cleanse Qlik logs text files from "C:\ProgramData\Qlik\Sense\Log"

Hi team,

Can you please help me to setup a solution where older than one month Qlik logs will be cleansed automatically fromC:\ProgramData\Qlik\Sense\Log folder and sub folders:

 

rohitk1609_1-1630473971716.png

 

Thanks,

Rohit

 

Labels (1)
  • logs

1 Solution

Accepted Solutions
Sebastian_Linser

Hello Rohit, 

 

yes the files are called .log even if they are shown as Text Document in Windows Explorer, you want to enable the option "File name extentions" under view

Sebastian_Linser_0-1630564260934.png

Here a screenshot of my destination, as you can see subfolders are created accordingly folder.

Sebastian_Linser_1-1630564309474.png

The specific one you mentioned (Servername_AuditActivity_Engine.log)bove are some which would be moved to the qlik shared folder archived logs path. If it hasnt been moved from e.g. C:\ProgramData\Qlik\Sense\Log\Engine\Audit then the service had problems reaching the share at service start, or the file was locked.

best regards

Sebastian

 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

5 Replies
Sebastian_Linser

Hello @rohitk1609 ,

you could do something like this:

 

  #Moves files older than 31 days old from the Source folder to the Target with creating the folders in the destination folder. 
  $sourcepath="C:\ProgramData\Qlik\Sense\Log"
  $destinationpath="C:\temp"
  Get-Childitem -Path $sourcepath -Filter *.log -Recurse -File  | Where-Object { $_.LastWriteTime -lt (get-date).AddDays(-31)} |
  ForEach {
        $destinationpathwithfolder=$destinationpath+$_.FullName.Substring(25,$_.FullName.Length-25) 
       New-Item -ItemType File -Path $destinationpathwithfolder -Force
    Move-Item $_.FullName -destination $destinationpathwithfolder -force -ErrorAction:SilentlyContinue

  }

 

Just exchange the Destination folder to where you want to have the files. Another option is robocopy if powershell is limited on your system.

 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
rohitk1609
Master
Master
Author

Hi Sebastian,

Thanks for your valuable input.

 

Sorry I am not good with Powershell. Just trying to understand the your code

The code you have shared, will send files older than 31, days from folder and its sub folders to new destination same name folder and same name destination folders?

Or we need to run this piece of code for each folder and its sub folders ? 

 

Thanks,

Rohit

Sebastian_Linser

 

Hello Rohit,

Just with the main folder, all sub folders which don't exist will be automatically created on the destination side. 

So you could in theory run this as scheduled task. I have also limited the files to just *.log otherwise it moves config files and qvd's as well.

 

Regards Sebastian

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
rohitk1609
Master
Master
Author

If I got your instruction correctly, We just need to run this Powershell script at "C:\ProgramData\Qlik\Sense\Log", all sub folders will be created automatically, and files present in main and sub folders will be moved to corresponding destination main folder and sub folders. 

One of the folder has file with name "201912161717323770000" or another folder has file likServer_AuditActivity_Engine_2019-12-17, I hope both files will go to their corresponding folders.

 

I didn't get filtering files with *.log.

Files I can see in Log folders as text files. Is .log is their extension .log?

rohitk1609_1-1630521579624.png

 

Please help me to understand what I am missing?

Thanks,

Rohit

 

 

 

 

Sebastian_Linser

Hello Rohit, 

 

yes the files are called .log even if they are shown as Text Document in Windows Explorer, you want to enable the option "File name extentions" under view

Sebastian_Linser_0-1630564260934.png

Here a screenshot of my destination, as you can see subfolders are created accordingly folder.

Sebastian_Linser_1-1630564309474.png

The specific one you mentioned (Servername_AuditActivity_Engine.log)bove are some which would be moved to the qlik shared folder archived logs path. If it hasnt been moved from e.g. C:\ProgramData\Qlik\Sense\Log\Engine\Audit then the service had problems reaching the share at service start, or the file was locked.

best regards

Sebastian

 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂