java - How do I access a property from log4j.properties in a JUnit test? -


i'm writing unit test validate logging functionality checking log file. started log path hard coded in test case, i'd rather use entry log4j.appender.file.file in log4j.properties file, in case changes. there way access programmatically inside junit code?

and in case wondering: functionality i'm testing in privates, can't check return values.

you can access programmatically using following:

fileappender appender = (fileappender) logmanager.getrootlogger().getappender("file"); file file = new file(appender.getfile()); 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -