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

Added Maven dependency example #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,56 @@ recommended Java logging API within Google.

### 1. Add the dependencies on Flogger

All code that uses flogger should depend on
`com.google.flogger:flogger:<version>` and
`com.google.flogger:flogger-system-backend:<version>`.
All code that uses flogger should depend on:

* `com.google.flogger:flogger:<version>`
* `com.google.flogger:flogger-system-backend:<version>`

**Maven**

```xml
<dependency>
<groupId>com.google.flogger</groupId>
<artifactId>flogger</artifactId>
<version>${flogger.version}</version>
</dependency>
<dependency>
Copy link
Member

@nick-someone nick-someone Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to move the NOTE from below to above the Maven subheading and add inline XML comments like:

<!-- only in root component of your application --> 

above flogger-log4j-backend

<groupId>com.google.flogger</groupId>
<artifactId>flogger-log4j-backend</artifactId>
<version>${flogger.version}</version>
<scope>runtime</scope>
</dependency>
```

Optionally
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please describe in what circumstances one would want to add the explicit dependency on log4j/exclusions? If I'm reading this directly, I don't know why/when I would do this instead of the first example above.

If the explanation is long enough, perhaps a footnote would help?

Copy link
Author

@clehene clehene Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nglorioso I don't know / remember. Flogger wasted more time than it saved to the point where we ended up debugging JUL in tears.

It manages to take something that typically causes problems (e.g. slf4j + X) and compounds that complexity into something more difficult. I'm not sure it's worth the trouble.

I may be too stupid / ignorant to actually figure it out. Currently have to do static blocks like

  static {
    System.setProperty("flogger.backend_factory", "com.google.common.flogger.backend.slf4j.Slf4jBackendFactory#getInstance");
  }

to get it working but for some reason this PR is still open...

Here's how the dependency management section looks like

      <dependency>
        <groupId>com.google.flogger</groupId>
        <artifactId>flogger</artifactId>
        <version>${google.flogger.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.flogger</groupId>
        <artifactId>flogger-system-backend</artifactId>
        <version>${google.flogger.version}</version>
        <scope>runtime</scope>
      </dependency>
      <dependency>
        <groupId>com.google.flogger</groupId>
        <artifactId>flogger-slf4j-backend</artifactId>
        <version>${google.flogger.version}</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>${logback.version}</version>
      </dependency>


```xml
<dependency>
<groupId>com.google.flogger</groupId>
<artifactId>flogger-log4j-backend</artifactId>
<version>${google.flogger.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
</dependency>
```

> Note: the dependency on `flogger-system-backend` is only required to be
included when the binary is run. If you have a modularized build, you can
Expand Down