Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter content before printing to log file using log4j

 
Hemant Khurana
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic