你可以問你的應用程序,以獲得從plugin.properties
甚至custom my.properties
文件的版本信息,就像在this thread:
public class MyPlugin extends AbstractUIPlugin {
protected final static String MY_PROPERTIES = "my.properties";
protected PropertyResourceBundle myProperties;
public PropertyResourceBundle getMyProperties(){
if (myProperties == null){
try {
myProperties = new PropertyResourceBundle(
FileLocator.openStream(this.getBundle(),
new Path(MY_PROPERTIES),false));
} catch (IOException e) {
this.logError(e.getMessage());
}
return myProperties;
}
...
從代碼中
然後你會打電話:
MyPlugin.getInstance().getMyProperties().getString("foo");
然後,這可以存儲在會話期間的靜態變量中,並在您的log4j輸出中重用噸。
非常感謝你,弗朗西斯! – 2009-12-07 12:10:21