Skip to content

Commit 85f37ac

Browse files
authored
Log message for doc parsing errors includes index name (elastic#118347)
* Throttled doc parsing error logging * add test * move throttler to separate class * small changes * refactor unittest * fix test * Log message for doc parsing errors includes index name
1 parent 43e298f commit 85f37ac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class DocumentMapper {
3030
private final MapperMetrics mapperMetrics;
3131
private final IndexVersion indexVersion;
3232
private final Logger logger;
33+
private final String indexName;
3334

3435
/**
3536
* Create a new {@link DocumentMapper} that holds empty mappings.
@@ -67,16 +68,17 @@ public static DocumentMapper createEmpty(MapperService mapperService) {
6768
this.mapperMetrics = mapperMetrics;
6869
this.indexVersion = version;
6970
this.logger = Loggers.getLogger(getClass(), indexName);
71+
this.indexName = indexName;
7072

7173
assert mapping.toCompressedXContent().equals(source) || isSyntheticSourceMalformed(source, version)
7274
: "provided source [" + source + "] differs from mapping [" + mapping.toCompressedXContent() + "]";
7375
}
7476

7577
private void maybeLog(Exception ex) {
7678
if (logger.isDebugEnabled()) {
77-
logger.debug("Error while parsing document: " + ex.getMessage(), ex);
79+
logger.debug("Error while parsing document for index [" + indexName + "]: " + ex.getMessage(), ex);
7880
} else if (IntervalThrottler.DOCUMENT_PARSING_FAILURE.accept()) {
79-
logger.info("Error while parsing document: " + ex.getMessage(), ex);
81+
logger.info("Error while parsing document for index [" + indexName + "]: " + ex.getMessage(), ex);
8082
}
8183
}
8284

0 commit comments

Comments
 (0)