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
Log messages are neither printed in the console nor saved into log file #549
Comments
I don't get any output to the logs on a production Lambda with this code – do you? Edit: sorry, I mean, I get the |
Here's the code I'm testing: import logging
logging.basicConfig(level=logging.INFO, format='[%(asctime)s] [%(levelname)s] %(message)s')
log = logging.getLogger(__name__)
def lambda_handler(event, context):
log.info("From log.info")
context.log("From context.log\n")
print("From print") And the output:
|
@bigunyak @mhart is correct. What you have does not work in the Lambda Service and therefore will not work locally. By some testing, it doesn't appear that import logging
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
def lambda_handler(event, context):
log.info("From log.info")
context.log("From context.log\n")
print("From print") So instead of using basicConfig, you should use Closing as this is not specific to the CLI and the CLI matches the Lambda Service. |
In SAM v0.4.0 log messages logged with
logging
module (python 3.6) are neither shown in the console nor printed in the log file with the--log-file
option.Looks like a regression bug after migrating to python implementation as the same issue was reportedly fixed in #91 and #124
Trivial code to reproduce the issue is below.
Print function works as expected but logging messages are missing.
The text was updated successfully, but these errors were encountered: