Cloud Watch agent locks files

0

Hello,

I want to send log files from the application to the AWS CloudWatch logs service. I created the required configuration of the CloudWatch agent and it is working fine but the CloudWatch agent service locks the "log file" on the server so the application cannot save any new information to this file.

Do you know how I can fix it?

Best Regards, Chris

posta 8 mesi fa229 visualizzazioni
1 Risposta
0

Hello.

What error occurs when trying to write logs from an application when the CloudWatch agent has a lock on the log file?

profile picture
ESPERTO
con risposta 8 mesi fa
  • The error says that the Powershell script cannot write to the log file because other processes handling the log file. I've checked in "Process Explorer" and that was Cloud Watch agent... Best Regards, Chris

  • How does the PowerShell script write to the log file? I would like to reproduce this in my environment.

  • Hello Riku, Thank you in advance ;)

    Please find below part of the PS code:

    $CurrDate = (Get-Date).ToString("yyyyMMdd") $logFile = "C:\Support\scripts\aws-test-rds-connection\logs\test-rds-connection-" + $CurrDate + ".txt"

    function Write-LogFile { param ([string]$logstring)

    $now = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss:fff - ")
    $line = ($now + $logstring)
    Add-Content $logFile -Value $line
    

    }

    Write-LogFile "Starting script"

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande