我想在添加数据库时记录对象:
Queue<Proposal> proposals = ...;
log.info(proposals.peek());
channelToDatabase.ingection(proposals.poll());
我的Proposal
对象:
public class Proposal {
/**
* Header of Proposal.
*/
private String header;
/**
* Author of Proposal.
*/
private String author;
/**
* Create date of Proposal.
*/
private Timestamp create;
/**
* Link to Proposal page.
*/
private String ulrPropose;
/**
* Account recruiter.
*/
private String urlRecruiter;
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
public String getNickname() {
return author;
}
public void setNickname(String author) {
this.author = author;
}
public Timestamp getCreateTime() {
return create;
}
public void setCreate(Timestamp create) {
this.create = create;
}
public String getUlrPropose() {
return ulrPropose;
}
public void setUlrPropose(String ulrPropose) {
this.ulrPropose = ulrPropose;
}
public String getUrlRecruiter() {
return urlRecruiter;
}
public void setUrlRecruiter(String urlRecruiter) {
this.urlRecruiter = urlRecruiter;
}
@Override
public String toString() {
return "Proposal{" +
"header='" + header + '\'' +
", author='" + author + '\'' +
", create=" + create +
", ulrPropose='" + ulrPropose + '\'' +
", urlRecruiter='" + urlRecruiter + '\'' +
'}';
}
}
我希望在我的信息日志中输入:
header, ulrPropose, time_addition, nickname, author, urlRecruiter
从我的数据库中选择,但在日志中。
我需要配置文件log4j.properties
。请帮帮我。
答案 0 :(得分:1)
您应该修改的是toString()函数Proposal,将其更改为您想要的格式。类似的东西:
cmd=service
你可以随意在互联网上选择log4j.properties,它会起作用。只记得更改只有“%m%n”的ConversionPattern,这样你就不会得到不必要的信息。