How to generate separate IQService log every day

Currently Iqservice log is stored in iqservice trace file and file gets appended.

I want it to be generate separate file every day. If possible if it can be appended with date.

Or if size exceeds after some threshold it should create a new one instead of appending old.

Can anyone please suggest on this?

Are you wanting to store what is in the existing IQService logs? Or different information that would be in an After Create/Modify PowerShell script?

If using the connector rules, there are examples here which include logging

If wanting to manipulate the existing log files, you could have a scheduled task that calls a PowerShell script to read the files and organize/manage them how you would like.

1 Like

This reference might come in handy in checking whether the ask is possible or not:
IQService Commands (sailpoint.com)

Ask is not related to native rule. I am asking about iqservice logs which is stored in IQTrace.
Currently all logs gets appended in IQTrace.log file. I want it be to be something like this based on date or size it creates a new file.
IQTrcce-01.log
IQTrcce-02.log
IQTrcce-03.log
IQTrcce-04.log

Have already checked this document, but it don’t help my requirement.
My requirement is:
Currently all logs gets appended in IQTrace.log file. I want it be to be something like this based on date or size it creates a new file.
IQTrcce-01.log
IQTrcce-02.log
IQTrcce-03.log
IQTrcce-04.log

In this scenario you have to leverage scheduled AD Task that will invoke a custom log management PSScript which will check the last modified metadata of IQService log and move them to a zipped state in a specific location.

Hi @Amrit1897,

You can use below sample PowerShell script and schedule it to run on regular interval and archive the file if it has reached a certain limit. Feel free to make changes in the snippet as per your use-case.

# Define variables
$logFilePath = "C:\Path\To\Your\logfile.log"
$archiveFolder = "C:\Path\To\Your\ArchiveFolder"
$maxFileSizeMB = 10

# Convert max file size to bytes
$maxFileSizeBytes = $maxFileSizeMB * 1MB

# Check if the log file exists
if (Test-Path $logFilePath) {
    # Get the file info
    $fileInfo = Get-Item $logFilePath

    # Check the file size
    if ($fileInfo.Length -gt $maxFileSizeBytes) {
        # Create archive folder if it doesn't exist
        if (-not (Test-Path $archiveFolder)) {
            New-Item -ItemType Directory -Path $archiveFolder
        }

        # Generate a timestamp
        $timestamp = Get-Date -Format "yyyyMMddHHmmss"

        # Define the archive file name
        $archiveFileName = "$($fileInfo.BaseName)_$timestamp$($fileInfo.Extension)"
        $archiveFilePath = Join-Path -Path $archiveFolder -ChildPath $archiveFileName

        # Move the log file to the archive location
        Move-Item -Path $logFilePath -Destination $archiveFilePath

        # Create a new, empty log file
        New-Item -ItemType File -Path $logFilePath
    }
}
else {
    Write-Host "Log file does not exist."
}

Thanks

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.