Logging unavailable at runtime unless `logging` tag passed to compile
If you create a new project using the Go template, no logging will be received unless the project is compiled with the logging tag.
This can be done by changing the makebuild file to include the tag, or running make with the TAGS environment variable defined:
TAGS=logging make
How can this be made more obvious?
Suggestions:
- add a comment in the generated
makebuildfile to note the values accepted byTAGSand the effect - add a comment in the generated
resource.godescribing how logging can be enabled - add documentation on the README
I found out the way to enable logging via a hint in https://github.com/aws-cloudformation/cloudformation-cli/issues/391; this could be made more discoverable for others.
We also stumbled upon this today. Wondering why logging isn't enabled by default? Deploying a custom Lambda that doesn't log anything is surprising, to say the least.
We also stumbled upon this today.
We followed the instructions of adding TAG=logging to the build process, but the CloudWatch Group was not created. Is there anything else that needs to be toggled as well, to see the logs of the custom resource?
@isimluk I'm having the same problem, did you get a resolution?
What would make this more obvious? README doc updates? Or do you think it would be better to remove the tagging and enable logging by default?
@kddejong My vote is README update including IAM Role settings- I have yet to get this to work.
It would be good to know if the resulting CloudWatch writer is compatible with logrus as well.
but the CloudWatch Group was not created
I checked my configuration -- it was a long time ago, and I don't remember doing anything special to get logging, and my IAM roles don't mention CloudWatch. Make sure you are passing the TAGS=logging to make correctly would be my advice.
It would be good to know if the resulting CloudWatch writer is compatible with
logrusas well.
I use zerolog, but it might be helpful to you. The framework sets up a Cloudwatch logger that is attached to the Go logging framework, so my configuration routes zerolog logs through to the Go logging system.
// Pass the Go logging framework writer as the target for zerolog. The CFN resource
// framework sets a custom Cloudwatch Logs writer on
// "log", so we need to use this to write zerolog output to Cloudwatch
// Logs too.
log.Logger = zerolog.New(golog.Writer()).
With().
Str("handler", handlerName).
Logger()
@isimluk I'm having the same problem, did you get a resolution?
I am sorry, I cannot remember. It has been a good while. Check you have proper permissions given to the lambda, that may be the root cause of not seeing any logs. Here is the lambda that I published a while ago and works fine.
I have CloudWatch logging working through logrus when the Resource is executed via a stack.
Anyone able to grab their logging when test-type is run? The best I can tell cfn is getting in the way.
Code snippet for logrus
import(
log "github.com/sirupsen/logrus"
ol "log"
)
....
log.SetOutput(ol.Writer())