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.
If enabled via quarkus.cxf.logging.enabled = true
, Quarkus CXF creates a global LoggingFeature
instance
and sets it on every client and service endpoint in the application.
The global settings can be overriden on the client or service endpoint level.
# Global settings
quarkus.cxf.logging.enabled = true
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.LoggingFeature
There is an example in Your first SOAP Web service chapter of the User guide.
or alternatively
-
Use the
@Features
annotation 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