diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 0106cdf..f95f12f 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3142,11 +3142,15 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
 	memset(zbuffer, 0, XLOG_BLCKSZ);
 	for (nbytes = 0; nbytes < XLogSegSize; nbytes += XLOG_BLCKSZ)
 	{
+		int			len;
+
 		errno = 0;
-		if ((int) write(fd, zbuffer, XLOG_BLCKSZ) != (int) XLOG_BLCKSZ)
+		if ((int) (len = write(fd, zbuffer, XLOG_BLCKSZ)) != (int) XLOG_BLCKSZ)
 		{
 			int			save_errno = errno;
 
+			elog(LOG, "write() in XLogFileInit returned %d: %m", len);
+
 			/*
 			 * If we fail to make the file, delete it to release disk space
 			 */
