Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging unavailable at runtime unless logging tag passed to compile #187

Open
jamestelfer opened this issue Dec 22, 2020 · 8 comments
Open
Assignees
Labels
bug Something isn't working Researching Researching

Comments

@jamestelfer
Copy link

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 makebuild file to note the values accepted by TAGS and the effect
  • add a comment in the generated resource.go describing how logging can be enabled
  • add documentation on the README

I found out the way to enable logging via a hint in aws-cloudformation/cloudformation-cli#391; this could be made more discoverable for others.

@mlafeldt
Copy link

mlafeldt commented Jul 28, 2021

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.

@brianterry brianterry self-assigned this May 16, 2022
@brianterry brianterry added bug Something isn't working Researching Researching labels May 16, 2022
@isimluk
Copy link

isimluk commented Jun 21, 2022

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?

@msummers-nr
Copy link
Contributor

@isimluk I'm having the same problem, did you get a resolution?

@kddejong
Copy link
Contributor

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?

@msummers-nr
Copy link
Contributor

msummers-nr commented Jun 13, 2023

@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.

@jamestelfer
Copy link
Author

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 logrus as 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
Copy link

isimluk commented Jun 14, 2023

@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.

@msummers-nr
Copy link
Contributor

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Researching Researching
Projects
None yet
Development

No branches or pull requests

6 participants