• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Filter content before printing to log file using log4j

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I have application which uses log4j and log4j.xml for logging purpose. I need to filter the content in loggers before printing to the log file.

For example I want that no String which is pattern A*BC*123 should get printed in log file through log4j.

So is there a way to add filters for specific content in log4j.

Thanks
Hemant
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know of a built-in regex filter, but there's a string matching filter that might be a good starting point.

I've never needed to filter on anything other than log levels, what's your use-case?
 
Hemant Khurana
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the application has some confidential data which it is printing in loggers right now. Though the confidential data is getting printed only in debug mode right now but the my requirement is to not to print that piece of data anytime in any logging mode.

Unfortunately I can not go and remove those loggers from the Java classes as there are too many of them and some are even inside jar for which I don't have the source code. Can you please guide me on how to use the String filters you are talking about. I'll see if can use that to satisfy my requirement

Thanks
Hemant
reply
    Bookmark Topic Watch Topic
  • New Topic