DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • MuleSoft: Tactical and Strategical Role of an Application Template
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)
  • Common Problems in React Native Apps on iOS Platform: Solutions and Tips
  • How To Verify Database Connection From a Spring Boot Application

Trending

  • Running Unit Tests in GitHub Actions
  • How To Learn Secure Software Development Lifecycle (SDLC)
  • Understanding Europe's Cyber Resilience Act and What It Means for You
  • TypeScript: Useful Features

Logging RCP Applications With Pax Logging

Patrick Paulin user avatar by
Patrick Paulin
·
Jul. 15, 09 · Interview
Like (0)
Save
Tweet
Share
7.69K Views

Join the DZone community and get the full member experience.

Join For Free

adding logging to an rcp application has always been painful. developers have struggled with the best way to incorporate log4j and other logging apis, and in particular with how to make configuration files accessible. some have chosen to use buddy classloading, others have utilized fragments containing the config files.

pax logging to the rescue

i’m happy to say that rcp developers now have another choice - pax logging . there are a few great things about this library:

  • installation is easy. i’ll describe this in a bit.
  • configuration files can be placed in regular folders, either inside of an application bundle or anywhere on a users machine.
  • many logging apis are supported, including log4j, commons logging, jdk logging, slf4j and more. this means that legacy and third-party code can run as-is no matter what logging api they use.

logging configuration with pax confman

because pax logging requires the osgi configuration admin service to work, your first step is to install this service in the form of pax confman. in my last blog post i provided detailed instructions on how to do this.

adding configuration settings

the good news is that once you install pax confman, you’re almost done! pax confman requires the pax logging bundles in order to work, so we only have a few minor steps left.

the first is to add a logging configuration file. when using the osgi configuration admin service, services are identified using a persistent identifier , or pid . developers can choose the pids for their own services, and an implementation of the config admin uses these pids to inject properties into services.

pax confman does this by requiring that a properties file be named based on the pid of the service it is going to configure. for example, the pax logging pid is org.ops4j.pax.logging and so the properties file for this service will be called org.ops4j.pax.logging.properties.

if you created the folder structure suggested in the pax confman setup, simply create a file called org.ops4j.pax.logging.properties in the confadmin/services directory. you can now place whatever logging configuration you like into this file. for instance, here’s what i have for my simple test project:

log4j.rootlogger=debug, a1

log4j.appender.a1=org.apache.log4j.consoleappender
log4j.appender.a1.layout=org.apache.log4j.patternlayout
log4j.appender.a1.layout.conversionpattern=%-4r [%t] %-5p %c %x - %m%n

log4j.logger.com.rcpquickstart.logtest=debug

forcing pax logging to start

just as we did with pax confman, its necessary to force pax logging to start up when our application is launched. to do this, we simply need add the org.ops4j.pax.logging.pax-logging-service bundle to the configuration page of the product configuration editor and set it’s auto-start property to true. if you’ve followed the instructions for installing pax confman, your complete list should look like this:

paxlogging-1

fire it up

that’s all there is to it. start up your rcp application and you should see log messages appear in your console.

paxlogging-2

happy logging!

from http://rcpquickstart.com

Pax (command) application Rich client platform

Opinions expressed by DZone contributors are their own.

Related

  • MuleSoft: Tactical and Strategical Role of an Application Template
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)
  • Common Problems in React Native Apps on iOS Platform: Solutions and Tips
  • How To Verify Database Connection From a Spring Boot Application

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: