Skip to content
Eden Gal edited this page Aug 10, 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.2</version>
</dependency>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <useIncrementalCompilation>false</useIncrementalCompilation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <Xlint>ignore</Xlint>
                    <complianceLevel>${java.version}</complianceLevel>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>com.datorama.oss</groupId>
                            <artifactId>timbermill-client</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Bootstrapping client

TImbermill client need to be bootstrap 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