Uh oh!
There was an error while loading. Please reload this page.
Do not setup log handlers to write to stderr - #758
Conversation
By setting up a handler in the library, the library users do not have a good control on how/where to write the logs. Do not set a handler from the library.
we should add docs and do a logging overhaul i think - e.g. https://github.com/testcontainers/testcontainers-java/blob/2707f3143d3cfa8351f727bfd5752c1155818bd6/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L665C1-L672C6 |
CarliJoy
commented
Mar 4, 2025
@alexanderankin what do you mean with a logging overhaul? Logging is always quite language specific as it requires global objects. I am with draftcode that a libary should not setup a logger, it only should log. I would even go that far, that the library should not even define the log level. It up to the user of the lib to define it. I.e. importloggingfromtypingimportFinalLOGGER: Final=logging.getLogger("testcontainers")
LOGGER.setLevel(logging.INFO)This would set the log level to all Besides this, there is nothing more to do. Why this is importantI am using testcontainers in pytest plugin, as I need containers to be started before imports are done (legacy code, that setups databases during import...). So being able to simply disable/change the handler all together would be nice. |
rhoban13
commented
May 26, 2025
Agree 💯 here. I'd go so far as to suggest |
alexanderankin
commented
Jun 19, 2025
closed in favor of #836 |
By setting up a handler in the library, the library users do not have a good control on how/where to write the logs. Do not set a handler from the library.