Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

log4j: assigning logging level per appender

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

I use log4j extensively in my application. I'm wondering if there's a way to set the logging level based on the appendering being used. For example, my rolling file appender I would like to set to debug logging level, while my console appender I would like to set to info, and my smtp appender to fatal.

I've looked through the log4j manual and while I can set the logging level based on a specific class package (i.e. foo.bar.com set to a different logging level than my root logger), I can't figure out a way to set the logging level based on the appender. Am I missing something?

Thanks,
Dave
 
Marshal
Posts: 26481
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think so. I just looked at the API documentation. The Logger class has a setLevel() method and the Appender class doesn't.

You could write an org.apache.log4j.spi.Filter object that denies logging events of whatever level you want to filter out, and add that to the appender in question.
 
I like tacos! And this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic