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 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
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

SerivceMix: Configuring Sift Appender with a Rolling Log File

Jason Sherman user avatar by
Jason Sherman
·
Mar. 04, 13 · Interview
Like (1)
Save
Tweet
Share
8.42K Views

Join the DZone community and get the full member experience.

Join For Free

I have come across several issues where people were having trouble configuring the Sift file appender in ServiceMix to enable per bundle logging.  Specifically, issues arose when trying to configure a rolling log file appender for sift.  This is rather simple and straight forward as you will see in the configuration below.  You simply need to use the org.apache.log4j.RollingFileAppender as you would for any log4j appender.  The important part is ensuring the proper configuration when applying the rolling log file appender to sift.

Lets have a look at the org.ops4j.pax.logging.cfg of the latest distribution of Fuse ESB, which is currently 4.4.1-fuse-03-06.  The Sift appender comes configured as follows:

 # Sift appender  
 log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender  
 log4j.appender.sift.key=bundle.name  
 log4j.appender.sift.default=servicemix  
 log4j.appender.sift.appender=org.apache.log4j.FileAppender  
 log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout  
 log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n  
 log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log  
 log4j.appender.sift.appender.append=true  

To enable a rolling log file we need to change:

log4j.appender.sift.appender=org.apache.log4j.FileAppender

to:

 log4j.appender.sift.appender=org.apache.log4j.RollingFileAppender  

Then we need to add the following properties to enable the rolling log:

 log4j.appender.sift.appender.maxFileSize=10MB   
 log4j.appender.sift.appender.maxBackupIndex=10  

Of course you would configure these properties as required by your application.

Now the Sift appender configured for rolling log files should look as follows:

 # Sift appender  
 log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender  
 log4j.appender.sift.key=bundle.name  
 log4j.appender.sift.default=servicemix  
 log4j.appender.sift.appender=org.apache.log4j.RollingFileAppender  
 log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout  
 log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n  
 log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log  
 log4j.appender.sift.appender.append=true  
 log4j.appender.sift.appender.maxFileSize=10MB   
 log4j.appender.sift.appender.maxBackupIndex=10  

That's all there is to it.  You now have a Sift appender configured for rolling log files.  Just remember you also need to have the rootLogger configured as follows to ensure the sift appender is activated.

Note: This is found at the top of the org.ops4j.pax.logging.cfg file.

 log4j.rootLogger=INFO, sift, osgi:VmLogAppender  



Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Using AI and Machine Learning To Create Software
  • PHP vs React
  • SAST: How Code Analysis Tools Look for Security Flaws
  • How and Why You Should Start Automating DevOps

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

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: