Technical Resources
Educational Resources
Connect with Us
logback is “intended as a successor to the popular log4j project.”
Papertrail supports aggregating messages from a native logback appender, providing a live searchable console for your Java (JRE/JVM) app logs, including Scala apps using frameworks like Lift and Play.
Papertrail can receive logback messages using logback-syslog4j (com.papertrailapp.logback.Syslog4jAppender
) or the older original logback ch.qos.logback.classic.net.SyslogAppender
. As described below, we recommend logback-syslog4j.
Install logback in your app or J2EE servlet container. This is basically adding the jars to your classpath, creating a logback.xml, and loading and invoking the classes to output messages (such as logger.debug("Success!");
).
logback outputs logs to one or more appenders (such as file, console, or syslog). Papertrail recommends the logback-syslog4j appender (com.papertrailapp.logback.Syslog4jAppender
) because it includes TCP, TCP with TLS, and Google App Engine support, as well as relying on syslog4j for message transmission.
If adding an appender to pom.xml
is not possible, or you prefer the standard logback SyslogAppender, this appender can also can send to Papertrail.
Visit logback-syslog4j README and follow the step-by-step instructions.
In the logback.xml
example in the README, replace host
and port
with the details from Papertrail’s Add Systems page. Replace ident
with a name of your app, or other attribute that Papertrail should use to identify the sending app.
To change the appearance of the sender name and program/calling method name in Papertrail:
<sendLocalTimestamp>false</sendLocalTimestamp> & <sendLocalName>false</sendLocalName> to <syslogConfig>
<ident>
tagSyslog4jAppender
with the following:<pattern>%d{MMM dd HH:mm:ss} HOSTNAME APPNAME: %-5level %logger{35}: %m%n%xEx</pattern>
HOSTNAME
will appear as the sender name in Papertrail, and APPNAME
will appear as the program.
Edit logback.xml
and add this within the <appenders>
block.
In the sample below, replace logsN
and XXXXX
with the details from Papertrail’s Add Systems page. Replace my-app
with a name of your app, or other attribute that Papertrail should use to identify this sender.
<appender name="PAPERTRAIL" class="ch.qos.logback.classic.net.SyslogAppender">
<syslogHost>logsN.papertrailapp.com</syslogHost>
<port>XXXXX</port>
<facility>USER</facility>
<suffixPattern>my-app: %logger %msg</suffixPattern>
</appender>
Outside of the appenders section (in the <root>
block), add this to enable the syslog appender you just created:
<appender-ref ref="PAPERTRAIL" />
An example might look like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} -
%msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="PAPERTRAIL" />
</root>
</configuration>
An alternative suffixPattern
that puts the %thread
variable in the position that’s used for clickable context (instead of my-app
above):
<suffixPattern>%thread: %-5level %logger{36} - %msg%n</suffixPattern>
Spark and logback rely on SLF4J, so to avoid including it twice it must be excluded as a dependency.
logback supports a debug mode for its own operations. To enable it, change the outer <configuration>
tag to <configuration debug="true">
.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.