How to log PDF Files using message Logging policy?

Hi All,

I'm working on a scenario where I receive PDF file from target systems. I'm receiving response as something like below.

 reponse.content: 

%PDF-1.7
%
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(en-US) /StructTreeRoot 17 0 R/MarkInfo<</Marked true>>/Metadata 127 0 R/ViewerPreferences 128 0 R>>
endobj
2 0 obj
<</Type/Pages/Count 3/Kids[ 3 0 R 11 0 R 14 0 R] >>
.......
......
......
...... and so on.

Say Apigee X convert it as  binary data by default and Now I want to log this response as is, using <CloudLogging> of MessageLogging policy. It's getting populated in APIGEE traces. But the log's are not visible in GCP's Log explorer. When it's json payloads, it's viewing absolutely fine.

Could u please help me with the PDF responses? Is there any setting that needs to be enabled? or is there a separate process to log PDF/Any other files?

Thanks,

Manoj Sai T.

Solved Solved
1 3 271
2 ACCEPTED SOLUTIONS

What do you want to appear in the logs, when you log a pdf to Cloud Logging?  

Cloud Logging, I think, accepts a JSON payload.   Not a PDF payload. 

What is the goal here?  

If you want the entire PDF to appear in cloud logging, you possibly could encode it (base64) and then wrapthat in the right JSON wrapper. But I think this solution is probably not a very good one, because PDFs can be QUITE LARGE and there is a size limit to the Cloud Logging log record. From my reading of the documentation, the limit is 256kb. 

So what is your goal?  Why do you want to log PDF files? What will the log records be used for?

View solution in original post

GREAT, sounds good.

View solution in original post

3 REPLIES 3

What do you want to appear in the logs, when you log a pdf to Cloud Logging?  

Cloud Logging, I think, accepts a JSON payload.   Not a PDF payload. 

What is the goal here?  

If you want the entire PDF to appear in cloud logging, you possibly could encode it (base64) and then wrapthat in the right JSON wrapper. But I think this solution is probably not a very good one, because PDFs can be QUITE LARGE and there is a size limit to the Cloud Logging log record. From my reading of the documentation, the limit is 256kb. 

So what is your goal?  Why do you want to log PDF files? What will the log records be used for?

Thanks for replying, @dchiesa1!

PFB the inline answers.

What do you want to appear in the logs, when you log a pdf to Cloud Logging?  - Last time I tried, Nothing is being logged in cloud logging when a PDF is passed as a response. No evidence of a transaction at all, on the log explorer.  We would need something on the log explorer which would at least tell about the incoming and outgoing transaction timings.

Cloud Logging, I think, accepts a JSON payload.   Not a PDF payload. - I see. Thanks for the info!

What is the goal here?  - Log explorer is working well with JSON payloads. But, no evidence at all  when a PDF is being passed. We would need something to be logged on Log explorer. 

If you want the entire PDF to appear in cloud logging, you possibly could encode it (base64) and then wrap that in the right JSON wrapper. But I think this solution is probably not a very good one, because PDFs can be QUITE LARGE and there is a size limit to the Cloud Logging log record. From my reading of the documentation, the limit is 256kb. - I'll try with encoding the binary data. Thanks for the info! Just wanted to tell you that I've also tried with PDFs, less than 100KB. But log explorer wouldn't show any transaction evidences.

So what is your goal?  Why do you want to log PDF files? What will the log records be used for? - If format restrictions doesn't allow PDFs, that should be fine. Else I just wanted to know how the way to log something when a PDF is passed.

GREAT, sounds good.