Skip to content

Easier way to configure logging #637

@lburgazzoli

Description

@lburgazzoli

So by default test containers logs in the following form:

14:42:17.885|INFO |🐳 [gcr.io/etcd-development/etcd:v3.3] - Creating container for image: gcr.io/etcd-development/etcd:v3.3
14:42:18.256|INFO |🐳 [gcr.io/etcd-development/etcd:v3.3] - Starting container with ID: e2f3eb78d0eb6b073271abcf30a76e675fe35f2212684935a36f3a28d4ee9a14

So if I want to log only warning I have to configure i.e. log4j2 as follow:

<Loggers>
    <!-- package loggers -->
    <Logger name="org.testcontainers" level="INFO" additivity="true"/>
    <Logger name="🐳 [gcr.io/etcd-development/etcd:v3.3]" level="WARN" additivity="true"/>

    <!-- main logger -->
    <Root level="INFO">
      <AppenderRef ref="STDOUT" />
    </Root>
  </Loggers>

Which means that I have to include:

  • the bits that generate the docker icon 🐳
  • the image name

So if I do upgrade the image or if I need to test against different images, I have to change also the logging configuration if I do not want to see testcontainers logs.

Maybe it is better to put the image name using MDC so one may decide to show it or not.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions