Log4j.properties
log4j.rootLogger=DEBUG, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\ParallelKMeansProject\\logs\\log.log
log4j.appender.file.MaxFileSize=50MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Main.java
SimpleKMeans model = new SimpleKMeans();
model.setNumClusters(K);
model.buildClusterer(data);
log.info(model);
log.log
Cluster 0:41.051205,28.808497 Cluster 1:41.055391,28.785407 Cluster 2:41.054838,28.802617 Cluster 3:41.022421,28.788169 Cluster 4: 41.024494,28.784099群集5:41.018659,28.787669群集6:41.040879,28.753359
我的问题
日志文件是* txt扩展名。这些日志在文件中并排编写。我想打印底线。如下;
Cluster 0:41.051205,28.808497
群集1:41.055391,28.785407
第2组:41.054838,28.802617
如何更改日志属性%-5p%c {1}:%L - %m%n