Skip to content
Eden Gal edited this page Nov 18, 2020 · 5 revisions

Server

Client

Maven configuration

Using maven as your dependency manager add the following to your pom.xml file

<dependency>
    <groupId>com.datorama.oss</groupId>
    <artifactId>timbermill-client</artifactId>
    <version>2.2.8</version>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/lib/</outputDirectory>
                        <includeArtifactIds>aspectjweaver,spring-instrument</includeArtifactIds>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Bootstrapping client

Add copied aspectjweaver-VERSION.jar and spring-instrument-VERSION.jar to from target/lib/ as java agents when running your app. java -javaagent:target/lib/aspectjweaver.jar -javaagent:target/lib/spring-instrument.jar -jar app.jar

Bootstrapping client

Timbermill client need to be bootstrapped at the start of the application, as follows:

TimbermillServerOutputPipeBuilder timbermillServerOutputPipeBuilder = new TimbermillServerOutputPipeBuilder().timbermillServerUrl(TIMBERMILL_SERVER_URL);
TimbermillServerOutputPipe pipe = timbermillServerOutputPipeBuilder.build();
Map<String, String> staticParams = new HashMap<>();
staticParams.put("applicationName", "test-app");
String env = "production";
TimberLogger.bootstrap(pipe, staticParams, env);

staticParams is a map holding fields names and value we want every task in Timbermill to present. env is a variable that is sent to the Timbermill server that determined to which environment this events belongs to. This can be used to differentiate between multiple environments applications (US/EU for example) that sends Timbermill events to the same Timbermill server.

The pipe, created by its builder, creates a thread that will be sending all the Timbermill events created to the Timbermill server. You should close when your app is shutting down using the exit method:

TimberLogger.exit();
Clone this wiki locally