I have to log the exception occurred in my java service in AWS cloud-watch
Here is my sample service
@GetMapping(value = "/GetUrl")
public String getURL(String key) throws FileNotFoundException
{
try {
return S3client.getUrl("xxxx", "xxxx.pdf").toString();
}
catch (AmazonS3Exception exception){
if(exception.getStatusCode() == 404){
throw new FileNotFoundException(key);
}
else{
throw exception;
}
}
}
If my catch block executed instead of throwing the exception have to call a class file to log the exception in AWS cloudwatch
how to achieve this functionality?
My java service will be going to be deployed in AWS instance docker container
Also if anyone has a better idea to achieve this functionality in some other way also please suggest