BATCH-1220: added debug logging in writers
This commit is contained in:
@@ -96,6 +96,10 @@ public class HibernateItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
*/
|
||||
protected void doWrite(HibernateOperations hibernateTemplate, List<? extends T> items) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Writing to Hibernate with " + items.size() + " items.");
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
long saveOrUpdateCount = 0;
|
||||
for (T item : items) {
|
||||
|
||||
@@ -96,6 +96,10 @@ public class JpaItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
*/
|
||||
protected void doWrite(EntityManager entityManager, List<? extends T> items) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Writing to JPA with " + items.size() + " items.");
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
long mergeCount = 0;
|
||||
for (T item : items) {
|
||||
|
||||
@@ -25,11 +25,14 @@ import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.WriteFailedException;
|
||||
import org.springframework.batch.item.WriterNotOpenException;
|
||||
import org.springframework.batch.item.database.JdbcBatchItemWriter;
|
||||
import org.springframework.batch.item.file.transform.LineAggregator;
|
||||
import org.springframework.batch.item.util.ExecutionContextUserSupport;
|
||||
import org.springframework.batch.item.util.FileUtils;
|
||||
@@ -56,6 +59,8 @@ import org.springframework.util.ClassUtils;
|
||||
public class FlatFileItemWriter<T> extends ExecutionContextUserSupport implements ResourceAwareItemWriterItemStream<T>,
|
||||
InitializingBean {
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(JdbcBatchItemWriter.class);
|
||||
|
||||
private static final String DEFAULT_LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
private static final String WRITTEN_STATISTICS_NAME = "written";
|
||||
@@ -182,6 +187,10 @@ public class FlatFileItemWriter<T> extends ExecutionContextUserSupport implement
|
||||
throw new WriterNotOpenException("Writer must be open before it can be written to");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Writing to flat file with " + items.size() + " items.");
|
||||
}
|
||||
|
||||
OutputState state = getOutputState();
|
||||
|
||||
StringBuilder lines = new StringBuilder();
|
||||
|
||||
@@ -66,9 +66,15 @@ public class JmsItemWriter<T> implements ItemWriter<T> {
|
||||
* @see org.springframework.batch.item.ItemWriter#write(java.util.List)
|
||||
*/
|
||||
public void write(List<? extends T> items) throws Exception {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Writing to JMS with " + items.size() + " items.");
|
||||
}
|
||||
|
||||
for (T item : items) {
|
||||
jmsTemplate.convertAndSend(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user