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

demandé il y a 8 mois228 vues
1 réponse
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
EXPERT
répondu il y a 8 mois
  • 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"

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions