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

gefragt vor 8 Monaten229 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 8 Monaten
  • 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"

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen