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

已提問 8 個月前檢視次數 229 次
1 個回答
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
專家
已回答 8 個月前
  • 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"

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南