I have a project which is in turn used by several other projects. I want log4j to log only my logs to a file that I have specified in the properties file. Other project use their own logging mechanisms and I have no control over them. My log4j files should not affect other project’s logging. How should i configure my log4j property file?
So far what I’m doing is setting log4j.rootLogger = ERROR and for my module log4j.logger.com.xyz.myproject = INFO, FILE. Will this work without affecting other project’s loggers? Or possibly limit logging to only my jar?
Thanks
It depends on the package structure of the other projects. Supposing that
Logger.getLogger(ClassA.class)ANDlog4j.category.loggerNamesettings ANDcom.abc.defand other projects have packages deeper in the hierarchycom.abc.def.ghiTHENchanging
com.abc.deflogging level would affect other projects – they’ll start logging on the level defined bycom.abc.def.Verify that it’s not the case and you should be safe.