[[message-logging]]
= Message Logging

include::./includes/attributes.adoc[]

For CXF https://cxf.apache.org/docs/message-logging.html[message logging], you can use the `quarkus-cxf-rt-features-logging` dependency, which supports native mode.

[source,xml,subs=attributes+]
----
<dependency>
    <groupId>io.quarkiverse.cxf</groupId>
    <artifactId>quarkus-cxf-rt-features-logging</artifactId>
    <version>{quarkus-cxf-version}</version>
</dependency>
----

As an example, you could create a `Producers` class which creates a pre-configured `LoggingFeature` instance.

[source,java]
----
import org.apache.cxf.ext.logging.LoggingFeature;

import io.quarkus.arc.Unremovable;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;

class Producers {

    @Inject
    @ConfigProperty(name = "mask.sensitiveElementNames")
    List<String> sensitiveElementNames;

    @Produces
    @ApplicationScoped
    @Unremovable
    LoggingFeature loggingFeature() {
        LoggingFeature loggingFeature = new LoggingFeature();
        loggingFeature.addSensitiveElementNames(new HashSet<>(sensitiveElementNames));
        loggingFeature.addSensitiveProtocolHeaderNames(new HashSet<>(Arrays.asList("Server", "Accept", "Date")));
        loggingFeature.setPrettyLogging(true);
        return loggingFeature;
    }
}
----

The `application.properties` file can then be configured as shown below.

[source,properties]
----
# Indexed properties to define which elements should be masked by the logger
mask.sensitiveElementNames[0]=password
mask.sensitiveElementNames[1]=ssn
mask.sensitiveElementNames[2]=address

# A web service endpoint with logging enabled
quarkus.cxf.endpoint."/greeting-service".features=org.apache.cxf.ext.logging.LoggingFeature

# A web service client with logging enabled
quarkus.cxf.client."greeting-client".features=org.apache.cxf.ext.logging.LoggingFeature
----

It is also possible to use the `LoggingInInterceptor` and `LoggingOutInterceptor` directly in your `application.properties` files as shown below.  The interceptors can be used for both service and client configurations.

[source,properties]
----
# A web service client with logging enabled using interceptors
quarkus.cxf.client."greeting-client".in-interceptors=org.apache.cxf.ext.logging.LoggingInInterceptor
quarkus.cxf.client."greeting-client".out-interceptors=org.apache.cxf.ext.logging.LoggingOutInterceptor
----
