Great,

Now I see:

2023-11-16 12:23:24,425 [T8N1TP1-1] INFO
(SID=C17CA9588C6F6CF41D30DB0AECC0F623)
(org.apache.cxf.ext.logging.slf4j.Slf4jEventSender:84) - REQ_OUT
    Address: https://beta.dosis.dev-vlaanderen.be/api/v1/dosis/csv
    HttpMethod: POST
    Content-Type: multipart/form-data;charset=UTF-8;
boundary="uuid:7b5c595d-9e46-49d3-95a9-342c1ebdcb75"
    ExchangeId: ec26163a-5cef-4d6d-b27d-5f880c56f168
    Headers: {Authorization=Bearer
9sUBhuW8SrHJwHVfAuY5jObVpMrHveQX2IPViJKgTSA, Accept=*/*}
    Payload:
--uuid:7b5c595d-9e46-49d3-95a9-342c1ebdcb75
Content-Type: text/csv
Content-Transfer-Encoding: binary
Content-ID: <root>
Content-Disposition:
form-data;name=file-0;filename=KMOP-Dossiers-Changed_20231116020250.csv

Agenten;Doorverwijzing;"DossierBeheerderAdresGemeente";"DossierBeheerderAdresNummer";"DossierBeheerderAdresPostCode";"DossierBeheerderAdresStraat";DossierBeheerderDienst;DossierBeheerderEmail;DossierBeheerderNaam;DossierBeheerderTelefoon;DossierBeheerderWebsite;ExtraInformatie;Bron;BronId;DossierNummer;IsPubliek;IsVertrouwelijk;LaatstBetaaldDeelBedrag;LaatsteDeelBetalingDatum;Naam;Producten;ProjectBedrag;ReedsBetaaldDeelBedrag;Actie;ActieNodig;"StatusDetail1";"StatusDetail2";StatusEDRL;StatusStreefDatum;StatusVlaamsCode;StatusVlaamsFase;StatusWijzigingsDatum;StreefDatum;TypeDossierCode;TypeSubsidieCode;UploadId;WijzigingsDatum
"0544495246:InkomGebruiker-gebruiker";"https://L-P53-008/op/ond/projectDetail.do?pid=2175317&elok=0544495246";;;;;;;;"1700";"https://www.vlaio.be/nl/subsidies-financiering/kmo-portefeuille/subsidies-aanvragen-en-ontvangen";"Dossier
voor de dienst opleiding ten bedrage van 270,00
euro.";"http://ewi.vlaanderen.be/vlaio/kmop";"21";"2022KMO155635";false;false;81.0;"2022-11-15T09:45:03.519Z";"Fiscale
eindejaarsoptimalisatie voor
vennootschappen";"198";81.0;81.0;;false;Afgewerkt;;Aanvaard;;Uitgevoerd;Afgerond;"2023-11-16T01:02:50.039Z";;DossierStatus;Deminimis;"7C672782-1F39-4353-KMOP-DFB795084A33-012258022";"2023-11-16T01:02:50.039Z"
"0885889320:InkomGebruiker-gebruiker";"https://L-P53-008/op/ond/projectDetail.do?pid=2175031&elok=0885889320";;;;;;;;"1700";"https://www.vlaio.be/nl/subsidies-financiering/kmo-portefeuille/subsidies-aanvragen-en-ontvangen";"Dossier
voor de dienst opleiding ten bedrage van 1.150,00
euro.";"http://ewi.vlaanderen.be/vlaio/kmop";"21";"2022KMO155349";false;false;345.0;"2022-11-15T08:00:37.899Z";"herstellen
premixketels";"198";345.0;345.0;;false;Afgewerkt;;Aanvaard;;Uitgevoerd;Afgerond;"2023-11-16T01:02:50.173Z";;DossierStatus;Deminimis;"7C672782-1F39-4353-KMOP-DFB795084A33-012258026";"2023-11-16T01:02:50.173Z"
...

--uuid:7b5c595d-9e46-49d3-95a9-342c1ebdcb75----uuid:7b5c595d-9e46-49d3-95a9-342c1ebdcb75

Regards,

J.P.

-----Original Message-----
From: Andriy Redko <drr...@gmail.com>
Sent: woensdag 15 november 2023 23:34
To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>; dev@cxf.apache.org
Subject: Re: Apache CXF JAXRS Logging questions

Hi Jean,

I think you could do something like that:

   Attachment att = new AttachmentBuilder()
                    .id("root")
                    .contentDisposition(root))
                    .mediaType("text/csv")
                    .object(Dossier.toCSV(dossiers))
                    .build()

(I would assume Dossier.toCSV(dossiers) returns a String).
Thank you.

Best Regards,
    Andriy Redko

JPU> Hi Andriy,

JPU> Currently I create the attachment like:
JPU>         ContentDisposition cd = new
JPU> ContentDisposition("form-data;name=file-0;filename="+filename);
JPU>         InputStream is = new
JPU>
ByteArrayInputStream(Dossier.toCSV(dossiers).getBytes(StandardCharsets.UTF_8));
JPU>         Attachment att = new Attachment("root",is, cd);

JPU> Although this work (i.e. is accepted by the server) it  is not the
JPU> appropriate way to generate an Attachment containing a csv file as
JPU> readable characters.

JPU>  The API docs refer to using
JPU> org.apache.cxf.jaxrs.ext.multipart.AttachmentBuilder but the
JPU> constructors don't give much information.
JPU> So what would be an appropriate way to send a csv-file that would
JPU> get logged?

JPU> Regards,

JPU> J.P. Urkens

JPU> -----Original Message-----
JPU> From: Andriy Redko <drr...@gmail.com>
JPU> Sent: zondag 12 november 2023 17:15
JPU> To: Jean Pierre URKENS <jean-pierre.urk...@devoteam.com>;
JPU> dev@cxf.apache.org
JPU> Subject: Re: Apache CXF JAXRS Logging questions

JPU> Hi Jean,

JPU> Getting back to you with the multipart logging, there are 2 parts
JPU> to it: the message content-type and boundary content-type. The
JPU> message content type is indeed multipart and is logged but it seems
JPU> like the boundary content type
JPU> (uuid:4ee36a2e-8382-4ef8-878b-0aedcab77c3b) is binary, this is why
JPU> it is logged as suppressed (binary boundary content is not logged,
JPU> as per AbstractLoggingInterceptor::stripBinaryParts).
JPU> Hope it helps, thank you.

JPU> Best Regards,
JPU>     Andriy Redko


>> Hi Andriy,
>> When sending a multipart/form-data request to a service endpoint I
>> see the following in the message log:
>> 2023-11-10 13:27:37,578 [T8N1TP1-4] INFO
>> (SID=D04AF2A21B0DCEFFE4724AEF745B5BDF)
>> (org.apache.cxf.ext.logging.slf4j.Slf4jEventSender:84) - REQ_OUT
>>     Address: http://L-P53-008:8085/dosis-server/csv
>>     HttpMethod: POST
>>     Content-Type: multipart/form-data;charset=UTF-8;
>> boundary="uuid:4ee36a2e-8382-4ef8-878b-0aedcab77c3b"
>>     ExchangeId: d87098e4-fe86-4a42-8985-37a6ccc90b1d
>>     Headers: {Authorization=Bearer
>> 11a5b872-be3f-49f8-a26f-fbeb9be56a66,
>> Accept=*/*}
>>     Payload:
>> --uuid:4ee36a2e-8382-4ef8-878b-0aedcab77c3b
>> --- Content suppressed ---
>> ----uuid:4ee36a2e-8382-4ef8-878b-0aedcab77c3b
>> 2023-11-10 13:27:37,661 [T8N1TP1-4] INFO
>> (SID=D04AF2A21B0DCEFFE4724AEF745B5BDF)
>> (org.apache.cxf.ext.logging.slf4j.Slf4jEventSender:84) - RESP_IN
>>     Address: http://L-P53-008:8085/dosis-server/csv
>>     ResponseCode: 200
>>     ExchangeId: d87098e4-fe86-4a42-8985-37a6ccc90b1d
>>     Headers: {transfer-encoding=chunked, Date=Fri, 10 Nov 2023
>> 12:27:37 GMT} I.e. the logging of the multipart form-data gets
>> suppressed.
>> I tried enabling it by setting the LoggingFeature (although according
>> to the Javadoc ‘logMultipart defaults to true’) on the
>> JAXRSClientFactoryBean
>> e.g.:
>>         public Response dossiersOpladen(List<Dossier> dossiers,
>> String
>> filename) throws GeneralSecurityException, AuthorizationException,
>> DosisCommunicationException, BusinessException {
>>                 try {
>>                         //Create the web client
>>                         String baseAddress =
>> Configuration.getInstance().getItem("dosis.service.base.uri");
>>                         clientProxy =
>> getThreadsafeProxy(baseAddress+"/csv");
>>                         Client client = WebClient.client(clientProxy);
>>                         WebClient webClient =
>> WebClient.fromClient(client);
>>
>> WebClient.getConfig(webClient).getHttpConduit().getClient().setReceiv
>> eTimeout(60000L);
>>
>> webClient.type(MediaType.MULTIPART_FORM_DATA_TYPE.withCharset(Standar
>> d
>> Charsets.UTF_8.name()));
>>
>>                         //Authorize API client by adding an
>> appropriate authorization header
>>                         authorizationHandler.authorize(webClient);
>>
>>                         //POST the request
>>                         log.info("Uploading dossiers from csv");
>>                         ContentDisposition cd = new
>> ContentDisposition("form-data;name=file-0;filename="+filename);
>>                         InputStream is = new
>> ByteArrayInputStream(Dossier.toCSV(dossiers).getBytes(StandardCharsets.UTF_8));
>>                         Attachment att = new Attachment("root",is, cd);
>>                         return webClient.post(new MultipartBody(att));
>>                 } catch (JsonProcessingException e) {
>>                         throw new BusinessException("Exception using
>> REST
>> service: "+e.getMessage(),e);
>>                 }
>>         }
>>         private static DosisService getThreadsafeProxy(String
>> baseAddress) throws GeneralSecurityException {
>>                 JacksonJsonProvider jjProvider = new
>> JacksonJsonProvider(new CustomObjectMapper());
>>                 List<Object> providers = Arrays.asList(new
>> MultipartProvider(), jjProvider);
>>
>>                 final JAXRSClientFactoryBean factory = new
>> JAXRSClientFactoryBean();
>>                 factory.setAddress(baseAddress);
>>                 factory.setServiceClass(DosisService.class);
>>                 factory.setProviders(providers);
>>                 factory.getOutInterceptors().add(new
>> LoggingOutInterceptor());
>>                 factory.getInInterceptors().add(new
>> LoggingInInterceptor());
>>                 factory.setThreadSafe(true);
>>
>>                 LoggingFeature feature = new LoggingFeature();
>>                 feature.setLogMultipart(true);
>>                 feature.setLogBinary(true);
>>                 factory.setFeatures(Arrays.asList(feature));
>>                 DosisService api = factory.create(DosisService.class);
>>                 return api;
>>         }
>> But still it doesn’t show anything. So how can I get this logged (for
>> testing purposes)?
>> Another question: Is it possible to get REST messages for different
>> endpoints to be logged to different files?
>> Currently I just include the Logging[In|Out]Interceptor and have
>> logging set through Log4J:
>> # Logging for CXF webservices
>> log4j.appender.WS=org.apache.log4j.DailyRollingFileAppender
>> log4j.appender.WS.File=${catalina.base}/logs/kmopFrontend-ws.log
>> log4j.appender.WS.encoding=UTF-8
>> log4j.appender.WS.datePattern=yyyy-MM-dd
>> log4j.appender.WS.layout=org.apache.log4j.PatternLayout
>> log4j.appender.WS.layout.ConversionPattern=%d{ISO8601} [%t] %-5p
>> %X{sessionId} (%C:%L) - %m%n log4j.additivity.org.apache.cxf=false
>> log4j.logger.org.apache.cxf=INFO,WS
>> This however doesn’t allow me to differentiate between (completely
>> different and unrelated) service endpoints. Everything gets logged in
>> the same file.
>> Regards,
>> J.P. Urkens

Reply via email to