Stream error_log to cloudwatch

When running with the `--console-log` flag, the gerrit daemon used to
send the logs only to stderr, ignoring the 'log.textLogging'
configuration, which instructs gerrit to log on the error_log file.

Since stable-3.0, this has been fixed[1].

This means that, for some gerrit versions, the error_log is also
available to be streamed to cloudwatch logs.

Add error_log to the list of files streamed to cloudwatch, so that (when
available) it can be easily identified by name and its content easily
distinguished from all other outputs sent to stderr.

From gerrit 3.3 this feature is widely available, however it is only
available from some minor versions prior to that. Spefically:

* from 3.0.13
* from 3.1.10
* from 3.2.5

[1]https://gerrit-review.googlesource.com/c/gerrit/+/276819
been
error logs to stderr

Bug: Issue 14439
Change-Id: I9367ec39c9cd14e6aa6233148f2345b450393ae1
diff --git a/README.md b/README.md
index cd8fce3..84d0f44 100644
--- a/README.md
+++ b/README.md
@@ -59,3 +59,42 @@
 
 If you need a testing LDAP server you can find details on how to easily
 create one in the [LDAP folder](ldap/README.md).
+
+## Logging
+
+All recipes stream every log to CloudWatch. This always includes `sshd_log`,
+`httpd_log` and `gc_log`.
+
+#### error_log
+The 'error_log' might or might not be available depending on which version of
+gerrit is being deployed.
+From gerrit 3.3 it will always be available.
+Prior to that it will be available from:
+
+* stable-3.0 -> starting from 3.0.13
+* stable-3.1 -> starting from 3.1.10
+* stable-3.2 -> starting from 3.2.5
+
+When the `error_log` is not available, Gerrit will still output the same content
+to standard error. Refer to the [standard error section](#standard-error).
+
+#### Standard error
+Different recipes deploy different services to ECS (please refer to the
+documentation of each recipe for details on what services are actually deployed).
+
+Every ECS service will stream anything outputted to stderr to cloudwatch, to a
+stream name that will take the form of:
+
+```
+{environmentName}/{serviceName}/{taskId}
+```
+
+For example, given the `gerrit-primary` service running task
+`bb21cb504ca44150b770ca05e922e332`, on the `test` environment, the stderr will
+be streamed to:
+
+```
+test/gerrit-primary/bb21cb504ca44150b770ca05e922e332
+```
+
+The task name can be found in the Amazon ECS console's `Task` section.
\ No newline at end of file
diff --git a/common-templates/cf-primary-asg.yml b/common-templates/cf-primary-asg.yml
index 6d1b2b9..0b09086 100644
--- a/common-templates/cf-primary-asg.yml
+++ b/common-templates/cf-primary-asg.yml
@@ -177,6 +177,11 @@
                       \"log_stream_name\": \"${EnvironmentName}/{instance_id}/$PRIMARY_ID/httpd_log\",
                       \"timezone\": \"UTC\"
                       },
+                      {\"file_path\": \"/gerrit-mount-point/gerrit-logs/error_log\",
+                      \"log_group_name\": \"${LogGroupName}\",
+                      \"log_stream_name\": \"${EnvironmentName}/{instance_id}/$PRIMARY_ID/error_log\",
+                      \"timezone\": \"UTC\"
+                      },
                       {\"file_path\": \"/gerrit-mount-point/gerrit-logs/sshd_log\",
                       \"log_group_name\": \"${LogGroupName}\",
                       \"log_stream_name\": \"${EnvironmentName}/{instance_id}/$PRIMARY_ID/sshd_log\",
diff --git a/dual-primary/README.md b/dual-primary/README.md
index 0c0bc8e..137a3a4 100644
--- a/dual-primary/README.md
+++ b/dual-primary/README.md
@@ -138,7 +138,8 @@
 ### Logging
 
 * All the logs are forwarded to AWS CloudWatch in the LogGroup with the cluster
-  stack name
+  stack name. Please refer to the general [logging documentation](../README.md#logging)
+  for further information on logging.
 
 ### Monitoring
 
diff --git a/primary-replica/README.md b/primary-replica/README.md
index ccb37d7..ed0fd7f 100644
--- a/primary-replica/README.md
+++ b/primary-replica/README.md
@@ -46,8 +46,9 @@
 
 ### Logging
 
-* Gerrit `error_log` is exported in a Log Group in CloudWatch
-* Other Gerrit logs still need to be exported
+* All the logs are forwarded to AWS CloudWatch in the LogGroup with the cluster
+  stack name. Please refer to the general [logging documentation](../README.md#logging)
+  for further information on logging.
 
 ### Monitoring
 
diff --git a/primary-replica/cf-cluster.yml b/primary-replica/cf-cluster.yml
index 3523810..acf14e3 100644
--- a/primary-replica/cf-cluster.yml
+++ b/primary-replica/cf-cluster.yml
@@ -253,6 +253,11 @@
                       \"log_stream_name\": \"${EnvironmentName}/{instance_id}/primary/httpd_log\",
                       \"timezone\": \"UTC\"
                       },
+                      {\"file_path\": \"/gerrit-mount-point/gerrit-logs/error_log\",
+                      \"log_group_name\": \"${AWS::StackName}\",
+                      \"log_stream_name\": \"${EnvironmentName}/{instance_id}/error_log\",
+                      \"timezone\": \"UTC\"
+                      },
                       {\"file_path\": \"/gerrit-mount-point/gerrit-logs/sshd_log\",
                       \"log_group_name\": \"${AWS::StackName}\",
                       \"log_stream_name\": \"${EnvironmentName}/{instance_id}/primary/sshd_log\",
diff --git a/single-primary/README.md b/single-primary/README.md
index caac341..66dd6ef 100644
--- a/single-primary/README.md
+++ b/single-primary/README.md
@@ -39,8 +39,9 @@
 
 ### Logging
 
-* Gerrit `error_log` is exported in a Log Group in CloudWatch
-* Other Gerrit logs still need to be exported
+* All the logs are forwarded to AWS CloudWatch in the LogGroup with the cluster
+  stack name. Please refer to the general [logging documentation](../README.md#logging)
+  for further information on logging.
 
 ### Monitoring
 
diff --git a/single-primary/cf-cluster.yml b/single-primary/cf-cluster.yml
index 7274596..6c6f9b4 100644
--- a/single-primary/cf-cluster.yml
+++ b/single-primary/cf-cluster.yml
@@ -192,6 +192,11 @@
                       \"log_stream_name\": \"${EnvironmentName}/{instance_id}/gc_log\",
                       \"timezone\": \"UTC\"
                       },
+                      {\"file_path\": \"/gerrit-mount-point/gerrit-logs/error_log\",
+                      \"log_group_name\": \"${AWS::StackName}\",
+                      \"log_stream_name\": \"${EnvironmentName}/{instance_id}/error_log\",
+                      \"timezone\": \"UTC\"
+                      },
                       {\"file_path\": \"/gerrit-mount-point/gerrit-logs/audit_log\",
                       \"log_group_name\": \"${AWS::StackName}\",
                       \"log_stream_name\": \"${EnvironmentName}/{instance_id}/audit_log\",