I really don't know how to do that with the log4j.properties.. Now, log4j does support using an log4j.xml file to set it up. usually its the same kind of convenience, of just dropping the log4j.xml into the top of the classpath instead of (remove and replace) the log4j.properties. Or if you do any other kind of elaborate set up logging by system property to log4j config file path.
The log4j.xml is more flexible, and powerful for setting up more elaborate kinds of things like different log files by package as you are looking to do.
1. Create a class with logger and create methods which call nothing but DEBUG()/INFO()/ ... etc.
2. Configure the above created class in log4j.propertis/log4j.xml.
3. Now call the above created methods to log messages other than package com.foo.X.
For full details you may follow this.
Don't get confused by the subject line used in the given url, what i described above, is available there.