Class Formatter
java.lang.Object
java.util.logging.Formatter
org.jboss.logmanager.ExtFormatter
eu.mulk.quarkus.googlecloud.jsonlogging.Formatter
public class Formatter
extends org.jboss.logmanager.ExtFormatter
Formats log records as JSON for consumption by Google Cloud Logging.
Meant to be used in containers running on Google Kubernetes Engine (GKE).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFormatter(Collection<StructuredParameterProvider> parameterProviders, Collection<LabelProvider> labelProviders) Constructs aFormatterwith custom configuration. -
Method Summary
Modifier and TypeMethodDescriptionformat(org.jboss.logmanager.ExtLogRecord logRecord) static Formatterload(Collection<StructuredParameterProvider> parameterProviders, Collection<LabelProvider> labelProviders) Constructs aFormatterwith parameter and label providers supplied byServiceLoader.Methods inherited from class org.jboss.logmanager.ExtFormatter
format, formatMessage, formatMessageLegacy, formatMessageNone, formatMessagePrintf, isCallerCalculationRequired
-
Constructor Details
-
Formatter
public Formatter(Collection<StructuredParameterProvider> parameterProviders, Collection<LabelProvider> labelProviders) Constructs aFormatterwith custom configuration.Note: This constructor does not automatically discover providers using the
ServiceLoadermechanism. Seeload(java.util.Collection<eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider>, java.util.Collection<eu.mulk.quarkus.googlecloud.jsonlogging.LabelProvider>)for this case use.- Parameters:
parameterProviders- theStructuredParameterProviders to apply to each log entry.labelProviders- theLabelProviders to apply to each log entry.
-
-
Method Details
-
load
public static Formatter load(Collection<StructuredParameterProvider> parameterProviders, Collection<LabelProvider> labelProviders) Constructs aFormatterwith parameter and label providers supplied byServiceLoader.In addition to the providers supplied as parameters, this factory method loads all
StructuredParameterProviders andLabelProviders found through theServiceLoadermechanism.- Parameters:
parameterProviders- theStructuredParameterProviders to apply to each log entry.labelProviders- theLabelProviders to apply to each log entry.- Returns:
- a new formatter.
-
format
- Specified by:
formatin classorg.jboss.logmanager.ExtFormatter
-