Add docker. prefix to container logger names, to enable log level to be set across all loggers#3018
Add docker. prefix to container logger names, to enable log level to be set across all loggers#3018vcvitaly wants to merge 4 commits intotestcontainers:mainfrom vcvitaly-forks:3016/root_overrides_container_logging_settings
docker. prefix to container logger names, to enable log level to be set across all loggers#3018Conversation
|
@bsideup please review? |
|
Sorry for the bump, any chance of reviewing this? I have a feeling this may help deal with #637 where it would be nice to set the log level for all dockers at once instead of matching against the 🐳... |
|
@vcvitaly please could you merge from master, or preferably give maintainers permission to edit? We've had some CI problems, so hopefully updating from master should fix things. |
|
Overall I think this looks fine and long overdue (sorry for the immense time to review). Let's just see the tests pass once rebased onto master and I think we should be good to go! |
docker. prefix to container logger names, to enable log level to be set across all loggers
|
I think it would be fair to say this fixes #637, although not in the way originally proposed. |
|
@rnorth I just can't find that checkbox to allow edits, I don't have it for some reason. I rebased onto the master. |
|
I’m afraid I’ll have to defer this to 1.15.1, so that we can review this together. We’re expecting to publish that release soon after 1.15.0, so it shouldn’t be too much delay. |
|
@rnorth Anything blocking this from being merged now, given that 1.15.1 is released? Would be incredibly nice to make the container logging be more easily controlled from e.g. |
|
@bsideup I think you had some ideas about how this could be done without a change to how it looks for normal use cases? |
| return LoggerFactory.getLogger("docker[" + abbreviatedName + "]"); | ||
| } | ||
| return LoggerFactory.getLogger(String.format( | ||
| "docker.%s[%s]", |
There was a problem hiding this comment.
I'd suggest avoiding brackets here. Some frameworks (e.g. Quarkus) give brackets a special meaning, and as a consequence, the following configuration would fail:
quarkus.log.category."docker.[foo:latest]".level=ERROROf course, this would work:
quarkus.log.category.docker.level=ERROR
But then we lose the ability to distinguish different containers.
I think a better approach would be to create a hierarchy of docker.<image name>.<label>, separated by dots.
Also, IMHO the little whale emoji is pretty, but only adds clutter when included in a logger name. Maybe move it to the log messages themselves?
There was a problem hiding this comment.
I agree @adutra. The whale emoji is cute but it totally doesn't belong in the actual logger name. 😂 So something like this would be preferable here:
return LoggerFactory.getLogger("docker." + abbreviatedName);Ideally, I think it should be prefixed with org.testcontainers though, so that all Testcontainers-based logging can be filtered away easily. org.testcontainers.docker would perhaps be the most suitable prefix here, i.e. this:
return LoggerFactory.getLogger("org.testcontainers.docker." + abbreviatedName);|
any progress on this? it is a bit more difficult to promote this library when logging is difficult to configure. (personally, I would prefer an org.testcontainers. prefix, but anything other than root will solve my problems.) |
|
Humble ping 🙂 |
|
Sorry, everyone, I am not sure why we let this go stale for some time now. We will look into it so that we can decide at least whether we will tackle this in a timely manner, or not at all. |
Sounds good @kiview, any updates on this yet? |
|
@vcvitaly - I added some feedback in https://github.com/testcontainers/testcontainers-java/pull/3018/files#r1006459726. If you're still with us, it would be nice to get these final details sorted out before this hopefully gets merged. If not, I am willing to take ownership of this change to make it be mergable. We really, really need to get this shipped anytime soon. It's a major pain related to e.g. CI logging right now. |
@perlun sorry, I almost forgot about this PR) let me review this within two days |
|
@kiview I renamed the logger as suggested by the community, please provide your feedback. |
|
Ping @kiview, is this mergable now or would it require any further adjustments? |
|
@eddumelendez - you seem to have been merging stuff recently. If you could help push things forward on this, it would be very greatly appreciated. 🙇 🙏 |
|
Anyone who talks to the maintainers recently, please ping them about this. I seem to be unable to get in touch with them despite repeated attempts. |
|
Hi, sorry for the delay on this one. We just started discussing about this internally. So, we will be sharing news hopefully soon. Thanks for your patience. |
|
@eddumelendez quite some time has passed since the PR was opened so here is a short review of the reasons why I opened it:
If something else is required from my side that might speed up pr review, I'd be happy to provide any additional info. |
| } else { | ||
| return LoggerFactory.getLogger("docker[" + abbreviatedName + "]"); | ||
| } | ||
| return LoggerFactory.getLogger("org.testcontainers.docker." + abbreviatedName); |
There was a problem hiding this comment.
| return LoggerFactory.getLogger("org.testcontainers.docker." + abbreviatedName); | |
| return LoggerFactory.getLogger("tc." + abbreviatedName); |
|
|
||
| assertThat(event.getFormattedMessage()).isEqualTo("some text"); | ||
| assertThat(event.getLevel()).isEqualTo(Level.DEBUG); | ||
| assertThat(event.getLoggerName()).startsWith("org.testcontainers.docker"); |
There was a problem hiding this comment.
| assertThat(event.getLoggerName()).startsWith("org.testcontainers.docker"); | |
| assertThat(event.getLoggerName()).startsWith("tc"); |
| <logger name="org.testcontainers.shaded" level="WARN"/> | ||
|
|
||
| </configuration> No newline at end of file | ||
| </configuration> |
There was a problem hiding this comment.
can we rollback this, please?
|
|
||
| @Test | ||
| public void debugIsNotSwallowedForContainerLogs() { | ||
| // Arrange |
There was a problem hiding this comment.
| // Arrange |
| listAppender.start(); | ||
| LOGGER.addAppender(listAppender); | ||
|
|
||
| // Act |
| // Act | ||
| LOGGER.debug("some text"); | ||
|
|
||
| // Assert |
There was a problem hiding this comment.
| // Assert |
Fixes #3016