public class CounterResolver extends Object implements EventResolver
config = [ start ] , [ overflowing ] , [ stringified ] start = "start" -> number overflowing = "overflowing" -> boolean stringified = "stringified" -> booleanUnless provided, start and overflowing are respectively set to zero and true by default.
When overflowing is set to true, the internal counter
is created using a long, which is subject to overflow while
incrementing, though garbage-free. Otherwise, a BigInteger
is used,
which does not overflow, but incurs allocation costs.
When stringified is enabled, which is set to false by default, the resolved number will be converted to a string.
Long.MAX_VALUE
is reached, counter overflows to Long.MIN_VALUE
.
{ "$resolver": "counter" }Resolves a sequence of numbers starting from 1000. Once
Long.MAX_VALUE
is reached, counter overflows to Long.MIN_VALUE
.
{ "$resolver": "counter", "start": 1000 }Resolves a sequence of numbers starting from 0 and keeps on doing as long as JVM heap allows.
{ "$resolver": "counter", "overflowing": false }
Constructor and Description |
---|
CounterResolver(EventResolverContext context,
TemplateResolverConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
resolve(LogEvent ignored,
JsonWriter jsonWriter)
Resolves the given
value using the provided JsonWriter . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isFlattening, isResolvable, isResolvable, resolve
public CounterResolver(EventResolverContext context, TemplateResolverConfig config)
public void resolve(LogEvent ignored, JsonWriter jsonWriter)
TemplateResolver
value
using the provided JsonWriter
.resolve
in interface TemplateResolver<LogEvent>
Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.