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.{method} is not displayed on console without config file #1392

Closed
heitorsilva opened this issue Nov 17, 2016 · 1 comment
Closed

Comments

@heitorsilva
Copy link

Hello!

I have a tornado app, that uses gunicorn 0.17.3 (I also tested with 19.6.0), and it's using logging.{info|error|debug} throughout the project.

If I run the app using gunicorn --access-logfile - --error-logfile - -b 0.0.0.0:3000 -w 1 -k tornado server:application, every logging method is not displayed on my console.

If I run the app using gunicorn --log-config logging.conf -b 0.0.0.0:3000 -w 1 -k tornado server:application, every logging method starts to be displayed on my console.

The conf file is like below:

[loggers]
keys=root, gunicorn_error, gunicorn_access, tornado_access

[handlers]
keys=console

[formatters]
keys=json

[logger_root]
level=DEBUG
handlers=console

[logger_gunicorn_error]
level=ERROR
handlers=console
propagate=0
qualname=gunicorn.error

[logger_gunicorn_access]
level=INFO
handlers=console
propagate=0
qualname=gunicorn.access

[logger_tornado_access]
level=INFO
handlers=console
propagate=0
qualname=tornado.access

[handler_console]
class=StreamHandler
formatter=json
args=(sys.stdout, )

[formatter_json]

For example, consider these lines:

print('=============== print - before ===============')
logging.info('=============== foobar - before ===============')
logging.debug('=============== foobar [debug] ===============')
myMiddleware(self.request)
print('=============== print - after ===============')
logging.info('=============== foobar - after ===============')
logging.debug('=============== foobar [debug] ===============')

Using the first method to run the app, the output is:

[2016-11-17 17:52:45 -0200] [14458] [INFO] Starting gunicorn 19.6.0
[2016-11-17 17:52:45 -0200] [14458] [INFO] Listening at: http://0.0.0.0:3000 (14458)
[2016-11-17 17:52:45 -0200] [14458] [INFO] Using worker: tornado
[2016-11-17 17:52:45 -0200] [14462] [INFO] Booting worker with pid: 14462
=============== print - before ===============
=============== print - after ===============

Using the second method to run the app, the output is:

Starting App with Tornado DEBUG = False
Connected to MongoDB. Hosts: localhost:27017. User: None. ReplicaSet:
=============== print - before ===============
=============== foobar - before ===============
=============== foobar [debug] ===============
=============== print - after ===============
=============== foobar - after ===============
=============== foobar [debug] ===============
GET on "/foo/bar" with filters: {}
304 GET /foo/bar (127.0.0.1) 9.29ms

Why those logging methods only work when using a config file? And why they only work with this logger_root directive?

Is there any relation to issues #379, #832, #1020, #1124, #1184, #1271, #1293, #1358 ?

How can I have those logging methods showing messages on console without using a config file? Is that possible?

@heitorsilva
Copy link
Author

In the end, my problem was on my server.py file and the way I was starting the app using Gunicorn or not.

Ignore this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant