我有下面的代码做序列化和保存在文件中的输出。我还想把这个写在log4j日志文件中,正确的方法是什么?
private ByteArrayOutputStream baos = new ByteArrayOutputStream();
public void writeToFile(){
try (FileOutputStream fileOut = new FileOutputStream(filePath, true)) {
baos.writeTo(fileOut);
this.baos.flush();
log.info(baos.toByteArray()) // Is this correct will it give me the same out put as above line ?
}catch (IOException e) {
logger.error("Error while writing query: ", e);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!