WSGI(gevent) logging to stdout and stderr












0














I'm trying to log my application and I want to use the logging module for it. The application is running in a docker-container, which made me to log to the stdout and stderr so I can see it in the docker logs. Unfortunately only my root logger is working who is writing to file. I already searched for this case, but I was unable to find a solution.



For better reference:



config.ini



[loggers]
keys=root, info

[handlers]
keys=debug, info

[formatters]
keys=debug, info, error

[logger_root]
level=DEBUG
handlers=debug

[logger_info]
level=INFO
handlers=info
qualname=docker.info
propagate=0

[handler_debug]
class=FileHandler
level=DEBUG
formatter=debug
args=('.logs', 'a+')

[handler_info]
class=StreamHandler
level=INFO
formatter=info
args=(sys.stdout,)

[formatter_debug]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s

[formatter_info]
format=%(levelname)s - %(message)s


main.py



import logging.config

logging.config.fileConfig(fname='logger.ini')
logger = logging.getLogger(__name__)

from gevent import monkey

monkey.patch_all()
from gevent import pywsgi

# some logging here

http_server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, log=logger)
http_server.serve_forever()









share|improve this question






















  • The name of the logger is related to __name__. root is a special case. info will apply for the package / module info only (everything starting with 'info' or 'info.')
    – Klaus D.
    Nov 12 '18 at 15:18










  • So I would need to rename info to root if I want to log to stdout?
    – Biskit1943
    Nov 12 '18 at 15:19










  • Got it, I removed every other logger and added all the handlers to the root logger. It's working now. If you wan't you can answer this question and I will mark it as solved.
    – Biskit1943
    Nov 12 '18 at 15:24
















0














I'm trying to log my application and I want to use the logging module for it. The application is running in a docker-container, which made me to log to the stdout and stderr so I can see it in the docker logs. Unfortunately only my root logger is working who is writing to file. I already searched for this case, but I was unable to find a solution.



For better reference:



config.ini



[loggers]
keys=root, info

[handlers]
keys=debug, info

[formatters]
keys=debug, info, error

[logger_root]
level=DEBUG
handlers=debug

[logger_info]
level=INFO
handlers=info
qualname=docker.info
propagate=0

[handler_debug]
class=FileHandler
level=DEBUG
formatter=debug
args=('.logs', 'a+')

[handler_info]
class=StreamHandler
level=INFO
formatter=info
args=(sys.stdout,)

[formatter_debug]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s

[formatter_info]
format=%(levelname)s - %(message)s


main.py



import logging.config

logging.config.fileConfig(fname='logger.ini')
logger = logging.getLogger(__name__)

from gevent import monkey

monkey.patch_all()
from gevent import pywsgi

# some logging here

http_server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, log=logger)
http_server.serve_forever()









share|improve this question






















  • The name of the logger is related to __name__. root is a special case. info will apply for the package / module info only (everything starting with 'info' or 'info.')
    – Klaus D.
    Nov 12 '18 at 15:18










  • So I would need to rename info to root if I want to log to stdout?
    – Biskit1943
    Nov 12 '18 at 15:19










  • Got it, I removed every other logger and added all the handlers to the root logger. It's working now. If you wan't you can answer this question and I will mark it as solved.
    – Biskit1943
    Nov 12 '18 at 15:24














0












0








0







I'm trying to log my application and I want to use the logging module for it. The application is running in a docker-container, which made me to log to the stdout and stderr so I can see it in the docker logs. Unfortunately only my root logger is working who is writing to file. I already searched for this case, but I was unable to find a solution.



For better reference:



config.ini



[loggers]
keys=root, info

[handlers]
keys=debug, info

[formatters]
keys=debug, info, error

[logger_root]
level=DEBUG
handlers=debug

[logger_info]
level=INFO
handlers=info
qualname=docker.info
propagate=0

[handler_debug]
class=FileHandler
level=DEBUG
formatter=debug
args=('.logs', 'a+')

[handler_info]
class=StreamHandler
level=INFO
formatter=info
args=(sys.stdout,)

[formatter_debug]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s

[formatter_info]
format=%(levelname)s - %(message)s


main.py



import logging.config

logging.config.fileConfig(fname='logger.ini')
logger = logging.getLogger(__name__)

from gevent import monkey

monkey.patch_all()
from gevent import pywsgi

# some logging here

http_server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, log=logger)
http_server.serve_forever()









share|improve this question













I'm trying to log my application and I want to use the logging module for it. The application is running in a docker-container, which made me to log to the stdout and stderr so I can see it in the docker logs. Unfortunately only my root logger is working who is writing to file. I already searched for this case, but I was unable to find a solution.



For better reference:



config.ini



[loggers]
keys=root, info

[handlers]
keys=debug, info

[formatters]
keys=debug, info, error

[logger_root]
level=DEBUG
handlers=debug

[logger_info]
level=INFO
handlers=info
qualname=docker.info
propagate=0

[handler_debug]
class=FileHandler
level=DEBUG
formatter=debug
args=('.logs', 'a+')

[handler_info]
class=StreamHandler
level=INFO
formatter=info
args=(sys.stdout,)

[formatter_debug]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s

[formatter_info]
format=%(levelname)s - %(message)s


main.py



import logging.config

logging.config.fileConfig(fname='logger.ini')
logger = logging.getLogger(__name__)

from gevent import monkey

monkey.patch_all()
from gevent import pywsgi

# some logging here

http_server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, log=logger)
http_server.serve_forever()






python logging flask wsgi gevent






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 15:13









Biskit1943

1481112




1481112












  • The name of the logger is related to __name__. root is a special case. info will apply for the package / module info only (everything starting with 'info' or 'info.')
    – Klaus D.
    Nov 12 '18 at 15:18










  • So I would need to rename info to root if I want to log to stdout?
    – Biskit1943
    Nov 12 '18 at 15:19










  • Got it, I removed every other logger and added all the handlers to the root logger. It's working now. If you wan't you can answer this question and I will mark it as solved.
    – Biskit1943
    Nov 12 '18 at 15:24


















  • The name of the logger is related to __name__. root is a special case. info will apply for the package / module info only (everything starting with 'info' or 'info.')
    – Klaus D.
    Nov 12 '18 at 15:18










  • So I would need to rename info to root if I want to log to stdout?
    – Biskit1943
    Nov 12 '18 at 15:19










  • Got it, I removed every other logger and added all the handlers to the root logger. It's working now. If you wan't you can answer this question and I will mark it as solved.
    – Biskit1943
    Nov 12 '18 at 15:24
















The name of the logger is related to __name__. root is a special case. info will apply for the package / module info only (everything starting with 'info' or 'info.')
– Klaus D.
Nov 12 '18 at 15:18




The name of the logger is related to __name__. root is a special case. info will apply for the package / module info only (everything starting with 'info' or 'info.')
– Klaus D.
Nov 12 '18 at 15:18












So I would need to rename info to root if I want to log to stdout?
– Biskit1943
Nov 12 '18 at 15:19




So I would need to rename info to root if I want to log to stdout?
– Biskit1943
Nov 12 '18 at 15:19












Got it, I removed every other logger and added all the handlers to the root logger. It's working now. If you wan't you can answer this question and I will mark it as solved.
– Biskit1943
Nov 12 '18 at 15:24




Got it, I removed every other logger and added all the handlers to the root logger. It's working now. If you wan't you can answer this question and I will mark it as solved.
– Biskit1943
Nov 12 '18 at 15:24












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265035%2fwsgigevent-logging-to-stdout-and-stderr%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265035%2fwsgigevent-logging-to-stdout-and-stderr%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues