Logback
How to configure rollbar-java to work with Logback
Installing
Maven
<dependencies>
<dependency>
<groupId>com.rollbar</groupId>
<artifactId>rollbar-logback</artifactId>
<version>1.9.0</version>
</dependency>
</dependencies>
Gradle
implementation('com.rollbar:rollbar-logback:1.+')
- Configure Rollbar in your
logback.xml
file.
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="ROLLBAR" class="com.rollbar.logback.RollbarAppender">
<accessToken>[post_server_item_access_token]</accessToken>
</appender>
<logger name="com.example.rollbar.logback" level="debug" additivity="false">
<appender-ref ref="ROLLBAR" />
</logger>>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
</configuration>
- Create a Rollbar logger in your code and log an exception.
Logger logger = LoggerFactory.getLogger("com.example.rollbar.logback");
logger.error(exception);
For further examples and information on using rollbar-logback, check out the example app here.
For more information on rollbar-java, please see the docs here.
Updated 10 months ago