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"

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠