Here's how to add the logback logging framework to your app on CloudBees, send the messages to Papertrail's log management service, and customize the verbosity for different app components.
We'll Create an app, Setup logback, and Customize logging.
We love us some pretty pictures:

We'll add these capabilities to your app's logging:
.. and a few other things, all to help the app tell you what's happening and why.
Although log4j gets more press, logback is often called its successor (background, differences). If you have a log4j.properties file, convert it.
Let's get down to business. If you already have an app on CloudBees, skip to Setup logback.
Here's how to create and deploy a new J2EE app on CloudBees. We'll create a skeleton Hello World app that also logs Hello World via logback.
Sign up for CloudBees and subscribe to 2 free subscriptions: RUN@Cloud and Papertrail.
On run.cloudbees.com, hit Add New Application, name it Hello World, and accept the defaults (details in Getting Started). You'll see a confirmation:
Your new application is now running at: http://helloworld.houseofawesome.cloudbees.net##
Click the Configuration tab and enable Papertrail:

and Save that change:

Install the CloudBees SDK - basically download, unzip, and set 2 variables. To verify that the SDK works, run this. Change the app ID to the one shown on your app's Configuration tab:
bees app:info -a houseofawesome/helloworld
You should see:
Create a new skeleton app per CloudBees' Maven Guide. Run its mvn archetype:create command, then merge its 2 pom.xml stanzas into your new myapp/pom.xml.
We've now got an app with CloudBees deployment tools. To see it locally, run bees app:run and browse to http://localhost:8080.
Now we'll add the logback dependencies, configure logback, add a logging call, and deploy the app.
Edit pom.xml again and add these to <dependencies>:
In myapp/src/main/resources/ (which should already exist), create a new file called logback.xml with:
This creates one logger we've called myapp, and sends output from all loggers to STDOUT at debug verbosity. Since your app uses the Papertrail subscription, CloudBees will automatically send standard output to Papertrail as it occurs. The <pattern> specifies a basic format.
In a typical servlet, use logback with:
Then generate a message at debug verbosity by calling:
logger.debug("Entering application.");
Obviously in production apps, keep logging in controllers and libraries. Since our skeleton app only has a single JSP, we'll change it to render "Hello World" in the browser and also output that to logback.
Edit myapp/src/main/webapp/index.jsp and insert these 4 lines anywhere:
Re-run mvn bees:run and reload http://localhost:8080. A new log line will appear each time you reload:
[http-8080-exec-1] INFO myapp - Hello World!
Once it's working locally, load Papertrail on CloudBees to see logs in realtime, and run:
mvn bees:deploy
.. to deploy the app. You'll see log messages appear as the app restarts. Then browse to your app's root URL; each page load should immediately generate a new log message in Papertrail's viewer.

Your app now has an easy way to describe state changes, unexpected conditions, object properties, and potential problems, and it's all visible and searchable as it happens. Here's a few things to customize or try:
Change myapp in logback.xml and in the getLogger call.
Troubleshooting? Check out the %caller{2} format option to include a 2-line mini-stack trace with line numbers. Change the <pattern> using these format specifiers.
Create multiple loggers and adjust the verbosity for each.
In an app with multiple components, one logger per component makes it easy to adjust the verbosity of only the one you're investigating (and puts the component/logger name in the message). Just add a logger entry to logback.xml and change the getLogger argument.
Even class-level verbosity is possible, like: LoggerFactory.getLogger(Foo.class);. Here's more.
Save a Papertrail search for something important. For example, try "Stopping Coyote" to see all restarts. Then save that search and create an alert to receive immediate pages or nightly emails:

Install Papertrail's command-line client: sudo gem install papertrail. More.