Logging
Refer to Quarkus Logging guide for basic information about logging on Quarkus, such as
-
Getting a logger in your application code
Payload logging
Historical note
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
Here is an example:
# Global settings
quarkus.cxf.logging.enabled-for = both
quarkus.cxf.logging.pretty = true
The global settings can be overriden on the client or service endpoint level.
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 = pretty
quarkus.cxf.endpoint."/hello".logging.limit = 256
# For a client:
quarkus.cxf.client.hello.logging.enabled = pretty
quarkus.cxf.client.hello.logging.sensitive-protocol-header-names = X-my-secret
|
All logging configuration options are documented on quarkus-cxf
reference page:
Alternative ways of adding a LoggingFeature
to a client or service
The quarkus.cxf*.logging.*
configuration options mentioned above will configure an internal instance of LoggingFeature
and attach it to the respective client or service.
There is no way how you can interact with this internal instance of LoggingFeature
programmatically.
If you need more control or if you migrate from other platforms, some of the following options may come in handy.
Produce 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
@Features
annotation of CXF
The @org.apache.cxf.feature.Features
annotation of CXF works too.
Here is how you can set an uncustomized instance of LoggingFeature
on a service implementation class.
@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;
}
//...
}