Class CounterResolver
java.lang.Object
org.apache.logging.log4j.layout.template.json.resolver.CounterResolver
- All Implemented Interfaces:
EventResolver,TemplateResolver<LogEvent>
Resolves a number from an internal counter.
Configuration
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.
Examples
Resolves a sequence of numbers starting from 0. OnceLong.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 Summary
ConstructorsConstructorDescriptionCounterResolver(EventResolverContext context, TemplateResolverConfig config) -
Method Summary
Modifier and TypeMethodDescriptionvoidresolve(LogEvent ignored, JsonWriter jsonWriter) Resolves the givenvalueusing the providedJsonWriter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.logging.log4j.layout.template.json.resolver.TemplateResolver
isFlattening, isResolvable, isResolvable, resolve
-
Constructor Details
-
CounterResolver
-
-
Method Details
-
resolve
Description copied from interface:TemplateResolverResolves the givenvalueusing the providedJsonWriter.- Specified by:
resolvein interfaceTemplateResolver<LogEvent>
-