I made mistake and didn't remove debugging lines from code before it was deployed to production and some information that shouldn't be in logs is in jboss log files. How can I make java program to filter all unwanted lines by keword? Or is there any tool for this already?
+1
A:
JBoss's logging is handled by log4j, and the log4j configuration file is conf/jboss-log4j.xml
. Have a look at this, and if necessary read the log4j manual, it should hopefully be fairly self-explanatory. If you need more help, then give us some examples of the lines you want removed.
skaffman
2009-11-26 10:48:22
A:
It sounds like you're asking how to remove certain lines from existing logs.
Here's what I use to remove DEBUG messages after enabling debugging in production for whatever reason:
perl -w -n -i -e 'print unless ( /DEBUG/../ERROR|WARN|INFO|FATAL/ && !/ERROR|WARN|INFO|FATAL/)' server.log.1
You can substitute whatever perlre matches just the lines you want to remove inside the parentheses above, for example:
perl -w -n -i -e 'print unless ( /SensitiveDebugInfo/ )' server.log.1
I'd be sure to only run this on logs that have been rolled over, to avoid potential file corruption from perl & jboss writing to the file simultaneously.
pra
2009-11-27 18:23:04