I have an app is built on GAE Flex Custom env (GCloud PHP Ngnix docker image based), I want to improve the application logging format.
How can I make the application log format better (more readable, with timestamp, POST/GET method name, status code (200), size (22 B), time (4ms), browser(chrome) in one line, put stack trace together instead of multiple lines now) like GAE logging format?
All of the following logs are from Google Cloud Platform Console, Logging page/tab.
(GAE default logging:)
15:21:23.667POST20022 B4 msChrome 56/User/isHuman
(my application log, I want to collect following lines into one part like above default one rather than multi lines:)
15:21:27.0002017/05/25 22:21:27 [error] 23#23: *34128 FastCGI sent in stderr: "PHP message: [WARN] jsVersion does not match:3617 3623
15:21:27.000 Stack Trace:
15:21:27.000Array
15:21:27.000(
15:21:27.000[0] => Array
--
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 google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
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/d8d50887-c512-451a-ac13-d91ecda235b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
"NOTICE: PHP message: Failed to send log to Google: {"
" "error": {"
" "code": 400,"
" "message": "Name is missing the logs component. Expected the form projects/[PROJECT_ID]/logs/[ID]","
" "status": "INVALID_ARGUMENT""
" }"
"}"
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/c935b2ca-feee-47e6-9b11-7083418f1f3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
$batchLogger = new PsrBatchLogger('app'); // logName `app`, tried both 'app' and 'my-project-id'
$batchLogger->log(LogLevel::DEBUG, 'This is a debug log');
$batchLogger->debug('This is a debug log'); // The same thing
- 2017/05/31 04:19:51 [error] 51#0: *1586 FastCGI sent in stderr: "PHP message: [INFO] Array - ( - [deviceId] => 0...C - [key] => 6....4 - [userId] => 1602 - )
> I think you can just use other PSR compliant logger, rather than using the PsrBatchLogger on your local machine.Could you give me some examples for other PSR compliant logger?
> Is this happening on App Engine Flex production server, or locally? ....It's on App Engine Flex production server. (I used my project id instead of 'app', but it still complains, what's appropriate way to set the name? just 'app' or 'projects/project-id/log/ID' as suggested?
my code:$batchLogger = new PsrBatchLogger('app'); // logName `app`, tried both 'app' and 'my-project-id'
$batchLogger->log(LogLevel::DEBUG, 'This is a debug log');
$batchLogger->debug('This is a debug log'); // The same thing
> The new logging library will automatically add some useful metadata (monitored resources, trace id, severity). They look very nice to me on the logging UI, but what do you mean exactly by making the format pretty?I mean there are a lot of logging separated in multiple lines (as following example) rather than list under a request like your screenshot.
- 2017/05/31 04:19:51 [error] 51#0: *1586 FastCGI sent in stderr: "PHP message: [INFO] Array - ( - [deviceId] => 0...C - [key] => 6....4 - [userId] => 1602 - )
On Thursday, May 25, 2017 at 3:36:25 PM UTC-7, Yao Li wrote:I have an app is built on GAE Flex Custom env (GCloud PHP Ngnix docker image based), I want to improve the application logging format.How can I make the application log format better (more readable, with timestamp, POST/GET method name, status code (200), size (22 B), time (4ms), browser(chrome) in one line, put stack trace together instead of multiple lines now) like GAE logging format?All of the following logs are from Google Cloud Platform Console, Logging page/tab.(GAE default logging:)15:21:23.667POST20022 B4 msChrome 56/User/isHuman(my application log, I want to collect following lines into one part like above default one rather than multi lines:)15:21:27.0002017/05/25 22:21:27 [error] 23#23: *34128 FastCGI sent in stderr: "PHP message: [WARN] jsVersion does not match:3617 362315:21:27.000 Stack Trace:15:21:27.000Array15:21:27.000(15:21:27.000[0] => Array
--
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 google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
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/366a25f6-6fd1-47ae-b4fb-bb6f5cbe7982%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/e00aad6a-b781-448c-8f7f-191737355b97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/e0c9ce76-9c05-4c26-957b-ee731d39b1e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/2cc20602-993f-4801-bd8d-9ddb8b896d8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
1. I tested gcr.io/google-appengine/php71 and PsrBatchLogger works on production, I will test more to make sure it doesn't influence performance too much.
2. I tested Monolog as well in production and it prints very fast but not under the request call (case 1) because it outputs to stdout/stderr. Is there any way to use Monolog to achieve the format when use PsrBatchLogger? (my production site has tons of traffic, Monolog prints locally and it's perfect if it can have pretty format like case 3)
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/52e74371-abc9-460e-b653-8700b43a1f33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.