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

Library has a binding on Log4j through SLF4J #14

Closed
Molyna opened this issue Mar 11, 2019 · 6 comments
Closed

Library has a binding on Log4j through SLF4J #14

Molyna opened this issue Mar 11, 2019 · 6 comments

Comments

@Molyna
Copy link

Molyna commented Mar 11, 2019

The library can cause a multiple binding and potentially overwrite the bindings on an application depending on it if that application doesn't use Log4j.

As per the SLF4J documentation:
Embedded components such as libraries not only do not need to configure the underlying logging framework, they really should not do so. They should invoke SLF4J to log but should let the end-user configure the logging environment. When embedded components try to configure logging on their own, they often override the end-user's wishes. At the end of the day, it is the end-user who has to read the logs and process them. She should be the person to decide how she wants her logging configured.

@taycaldwell
Copy link
Contributor

Thank you for the report, we are currently looking into this.

@zonder129
Copy link

I am having the same problem, please fix it as soon as possible! It's overriding my own logging properties and makes me really sad :(

@Molyna
Copy link
Author

Molyna commented Apr 22, 2019

@zonder129 you should be able to exclude the usage of log4j binding.

I don't have anything to test this with myself right now but something like this for gradle should potentially do it.
configurations { runtime.exclude group: "org.slf4j", module: "slf4j-log4j12" }

or

dependencies { compile group: 'com.google.actions', name: 'actions-on-google', version: '1.0.2' { exclude group: "org.slf4j", name: "slf4j-log4j12" } }

Or for Maven something like (I don't use Maven myself so this might need some work)

<exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions>

@zonder129
Copy link

@Molyna thank you, that is really great workaround, I totally forgot about exclude stuff. Thanks again!

@dzuluaga
Copy link

Thanks @Molyna for the suggestion. For Maven, this exclusion worked for me:

<dependency>
    <groupId>com.google.actions</groupId>
    <artifactId>actions-on-google</artifactId>
    <version>1.0.2</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Also, unrelated but if you're in the path of testing on Google App Engine Standard along with Spring Boot framework, you'll need to follow steps from Spring Boot App Engine Standard. Here are some steps, but not limited to. So, make sure you follow steps from the link above.

1) Use Servlet 3.1.0: Do not include the Jetty dependencies. But you must include Servlet API dependency:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

2) Remove Tomcat Starter After excluding Tomcat, the command ./mvnw spring-boot:run won't work anymore. You can still run Google App Engine locally by using the command ./mvnw appengine:run.

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
  </exclusions>
</dependency>

3) Exclude JUL to SLF4J Bridge

<!-- Exclude any jul-to-slf4j -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jul-to-slf4j</artifactId>
    <scope>provided</scope>
</dependency>

@taycaldwell
Copy link
Contributor

The log4j dependency has been removed as of https://github.com/actions-on-google/actions-on-google-java/releases/tag/v1.1.0

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

No branches or pull requests

5 participants