I have such log4j.properties
file:
#Wed Jan 18 12:55:30 EET 2017
log4j.rootLogger=ERROR, stdout, gui, clientFile
log4j.logger.app=DEBUG
...
And when I start my application first line with timestamp (#Wed Jan 18 12:55:30 EET 2017
) is always changing. It causes some problems with Git commits (I can not add this file to .gitignore).
Found what is adding the timestamp: this method is calling in app linkedProperties.store(fileOutputStream, null);
The implementation of store() method is from java.util.Properties.
package java.util;
...
public class Properties extends Hashtable<Object,Object> {
...
public void store(OutputStream out, String comments)
throws IOException
{
store0(new BufferedWriter(new OutputStreamWriter(out, "8859_1")),
comments,
true);
}
private void store0(BufferedWriter bw, String comments, boolean escUnicode)
throws IOException
{
if (comments != null) {
writeComments(bw, comments);
}
bw.write("#" + new Date().toString());
bw.newLine();
synchronized (this) {
for (Enumeration<?> e = keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)get(key);
key = saveConvert(key, true, escUnicode);
/* No need to escape embedded and trailing spaces for value, hence
* pass false to flag.
*/
val = saveConvert(val, false, escUnicode);
bw.write(key + "=" + val);
bw.newLine();
}
}
bw.flush();
}
...
How can I avoid this bw.write("#" + new Date().toString());
? Is there something similar to java.util.Properties?