I want to modify log files of existing builds. What function should be used for same need help regarding this
- solved #6
- replies 8
- views 1250
- stars 1
I have tried this
logStream = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(logFile), Bootstrap.BUFFER_SIZE)
logStream.writeObject(new_entry);
But what it does is replaces old log with new and doesn't append
logStream = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(logFile,true), Bootstrap.BUFFER_SIZE)
Probably because - https://stackoverflow.com/questions/1194656/appending-to-an-objectoutputstream
Basically you will need to read all entries to a List, and then add your entries to the list. Then finally write all entries in the list to original stream like below:
for (entry: entries) {
logStream.writeObject(entry);
}
logStream.writeObject(null); // indicate that the log reaches to end
logStream.close();
Thanks for the help. It works fine now.
I have one more query -
Even though log is modified in the backend but log displayed in view is not changed.
I defined all fields for BuildLogEntry object.
Please make sure:
Also make sure that you are doing this after build is finished, as otherwise, it will be overwritten by current build log.