Yes, it should be possible.
While this is possible with the wonderful javassist
i would not use javassist in this particular instance. log4j has a very flexible architecture, and you can do what you want to do by just changing the log4j configuration files, without changing your java class files at all.
It might be possible with log4j configuration files, but cannot be done in our environment.
This is because in our company, different components belong to different teams and each of them have their own configurations. We are not allowed in theory to change them since we are not the owners. All we get is an "ear" file which combines may be at least 20-30 different components. Hence I would prefer to use javassist to take this ear as input and create another ear as output which makes a weaving in all places were log4j statements are there and write an equivalent log to our convenient location. This way I need not depend on other application teams to tell the logs.
What's your valuable advise in such a scenarion? Thanks a lot