Hello Kishu,

I would like to confirm that you are using the example outlined in your 
initial link 
<https://cloud.google.com/logging/docs/reference/libraries#client-libraries-install-java>
 
and have replaced StringPayload with JsonPayload?

If that is the case, it would be my recommendation to utilise the actual 
JsonPayload code offered here 
<https://cloud.google.com/logging/docs/api/tasks/creating-logs> instead. 
The code from your original post is appropriate for StringPayload as 
JsonPayload requires its own specific import. You can find the imports 
required for this at the following example offered on GitHub 
<https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-examples/src/main/java/com/google/cloud/examples/logging/snippets/LoggingSnippets.java>.
 


However, I am still unsure of what you are trying to achieve. Stackdriver 
logging for Standard produces the following logs:

Request Logs- records requests that are sent to all App engine Apps (Type: 
Request Log).

App Logs- record activity within the App Engine app (Type: LogLine).

Third-party package logs- package logs that are included in Logs Viewer.

Based on this provided information, I would like to know where you intend 
these logs to go. (i.e: Request Logs or App logs specifically). You had 
mentioned you are seeing LogLines. I am assuming you are trying to publish logs 
within App Logs at this point.

If that is the case then it would be my recommendation to follow the 
guidelines expressed here 
<https://cloud.google.com/appengine/docs/standard/java/logs/#writing_application_logs>
 
for writing application logs. Note: you will notice that the guide mentions 
the import of the Java.Util library which is different than the cloud 
import required for Request logs.

As for your last question of “is structured logging possible in standard 
environment?”. I would like to inform you that JsonPayload is essentially 
Structured Logging. However if this not what you are expecting then I would 
have to request an example of what you want the log to look like.


On Friday, October 26, 2018 at 2:12:54 AM UTC-4, Kishu Agarwal wrote:
>
> Thanks Mohammad for the reply.  The link I shared did contain a example of 
> using the stackdriver logging library. Instead of StringPayload, I have 
> used JsonPayload only, but still I don't see anything in my logs.
>
> I want to clarify one doubt. Is structured logging possible in standard 
> environment? Because when I see my logs, I see logLines instead of logEntry 
> objects.
>
> On Friday, October 26, 2018 at 5:28:52 AM UTC+5:30, Mohammad I (Cloud 
> Platform Support) wrote:
>>
>> Hello Kishu,
>>
>> Please kindly note that the article that you provided does not have 
>> examples of structured logging. You can look into these documents instead 
>> for Structured Logging 
>> <https://cloud.google.com/logging/docs/structured-logging>explanation 
>> and for an example on how to write structured logs 
>> <https://cloud.google.com/logging/docs/api/tasks/creating-logs#writing_log_entries>.
>>  
>> For more information on different payload formats please look into this 
>> document LogEntry. 
>> <https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry> 
>> That being said, please use jsonPayload instead of StringPayload in 
>> order to log JSON data into your logs in Stackdriver Logging. 
>>
>>
>> On Wednesday, October 24, 2018 at 5:49:45 AM UTC-4, Kishu Agarwal wrote:
>>>
>>> I want to log json data in my logs. I have tried the steps mentioned 
>>> here 
>>> <https://cloud.google.com/logging/docs/reference/libraries#client-libraries-install-java>
>>>  but 
>>> still when I see my logs, all the log statements done using Logging doesn't 
>>> show up there.
>>>
>>> Any help there?
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/251869e3-d12c-4063-abdd-e8217d1467e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appe... Kishu Agarwal
    • [google... 'Mohammad I (Cloud Platform Support)' via Google App Engine
      • [go... Kishu Agarwal
        • ... 'Harmit Rishi (Cloud Platform Support)' via Google App Engine

Reply via email to