Logging
Refer to Quarkus Logging guide for basic information about logging on Quarkus, such as
-
Getting a logger in your application code
Payload logging
|
History
Since Quarkus CXF 2.6.0, the payload logging functionality is available via
|
The payload logging functionality is implemented primarily through the org.apache.cxf.ext.logging.LoggingFeature class.
There are several ways how you can set the feature on a client or service endpoint.
Configuring payload logging through configuration properties
Global settings
The global logging options exist since Quarkus CXF 2.6.0.
They need to be enabled using quarkus.cxf.logging.enabled-for.
There are four possible values:
-
none(default) - the global logging feature is enabled for neither clients nor service endpoints -
clients- the global logging feature is enabled for all clients in the application -
services- the global logging feature is enabled for all service endpoints in the application -
both- the global logging feature is enabled for all clients and service endpoints in the application
The global settings can be overriden on the client or service endpoint level.
# Global settings
quarkus.cxf.logging.enabled-for = both
quarkus.cxf.logging.pretty = true
All logging configuration options are listed on quarkus-cxf reference page.
|
All logging properties mentioned on this page are runtime configuration options.
Hence you can pass them when starting the application without having to rebuild it.
It can be done either by passing a system property on the command line (e.g. |
Per client and per service endpoint settings
Since Quarkus CXF 2.5.0, the LoggingFeature can be configured and attached to a client or a service
endpoint declaratively by setting the appropriate options in application.properties:
# For a service:
quarkus.cxf.endpoint."/hello".logging.enabled = true
quarkus.cxf.endpoint."/hello".logging.pretty = true
# For a client:
quarkus.cxf.client.hello.logging.enabled = true
quarkus.cxf.client.hello.logging.pretty = true
All logging configuration options are documented on quarkus-cxf reference page:
Alternative ways of adding a LoggingFeature to a client or service
To attach an instance with default settings, you can do one of the following:
-
In
application.properties:# For a service: quarkus.cxf.endpoint."/hello".features = org.apache.cxf.ext.logging.LoggingFeature # For a client: quarkus.cxf.client."myClient".features = org.apache.cxf.ext.logging.LoggingFeatureThere is an example in Your first SOAP Web service chapter of the User guide.
or alternatively
-
Use the
@Featuresannotation of CXF:@org.apache.cxf.feature.Features (features = {"org.apache.cxf.ext.logging.LoggingFeature"}) @WebService(endpointInterface = "org.acme.SayHi", targetNamespace = "uri:org.acme") public class SayHiImplementation implements SayHi { public long sayHi(long arg) { return arg; } //... }
Producing a custom LoggingFeature bean
If you need some custom logic to setup the LoggingFeature, you can produce a named LoggingFeature bean:
import org.apache.cxf.ext.logging.LoggingFeature;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
class Producers {
@Produces
@ApplicationScoped
@Named("limitedLoggingFeature") // "limitedLoggingFeature" is redundant if the name of the method is the same
LoggingFeature limitedLoggingFeature() {
LoggingFeature loggingFeature = new LoggingFeature();
loggingFeature.setPrettyLogging(true);
loggingFeature.setLimit(1024);
return loggingFeature;
}
}
Then you can refer to it by its name prefixed with # in application.properties:
# For a service:
quarkus.cxf.endpoint."/hello".features = #limitedLoggingFeature
# For a client:
quarkus.cxf.client.hello.features = #limitedLoggingFeature