Hi Yao,

Maybe you can use one of our base image:
gcr.io/google-appengine/php71
gcr.io/google-appengine/php70
gcr.io/google-appengine/php56

They have pcntl extension enabled by default.

On Thu, Jun 1, 2017 at 11:02 AM Yao Li <y...@sazze.com> wrote:

> 1. I stop using PsrBatchLogger in framework level logging and it doesn't
> have 499 error.
>
> 2. The logging sample works for me, thanks.
>
> 3. I found the error for PsrBatchLogger in the current project whose
> runtime is custom (based on gcr.io/google_appengine/debian8, but your
> logging example runtime is php) :
>
> PHP Fatal error:  Uncaught Error: Call to undefined function
> Google\Cloud\Core\Batch\pcntl_signal() in
> /app/vendor/google/cloud/src/Core/Batch/BatchDaemon.php:67
> Stack trace:
> #0 /app/vendor/google/cloud/src/Core/bin/google-cloud-batch(45):
> Google\Cloud\Core\Batch\BatchDaemon->__construct('/app/vendor/goo...')
> #1 {main}
>   thrown in /app/vendor/google/cloud/src/Core/Batch/BatchDaemon.php on
> line 67
> 2017-06-01 17:44:05,686 INFO exited: batch-daemon (exit status 255; not
> expected)
>
> The pcntl_signal() function should be disabled, I tested adding it into
> google_app_engine.enable_functions in application's php.ini, but it doesn't
> work. I'm trying to add it into custom docker image's php.ini. (the custom
> docker image is based on php-nginx, like php-docker
> <https://github.com/GoogleCloudPlatform/php-docker>, but not exact same,
> cannot found the original link).
>
> On Thursday, June 1, 2017 at 9:32:56 AM UTC-7, Takashi Matsuo (Google)
> wrote:
>
>>
>> Sorry I forgot to attach the app. Here you are.
>>
>> On Thu, Jun 1, 2017 at 9:25 AM Takashi Matsuo <tma...@google.com> wrote:
>>
>
>>> Hi Yao,
>>>
>>> I don't see any 499 errors in your logs. Is that still happening?
>>>
>>> The logs are saying `child 53 said into stderr`, which means you are
>>> emitting the logs to stderr, but the psrBatchLogger doesn't. I don't think
>>> your configuration is correct. Can you create and deploy a simple project
>>> with the psrBatchLogger and select `nginx.request` and `app` in the log
>>> console? I attached the working sample app, so that you can just try it
>>> rather than writing it on your own. It produces the following log
>>> presentation when you expand a `nginx.request` log:
>>>
>>> [image: LogUI.png]
>>>
>>> Be sure to select `app` and `nginx.request` logs as follows:
>>>
>>>
>>> [image: app-nginx.request.png]
>>>
>> On Thu, Jun 1, 2017 at 8:56 AM Yao Li <y...@sazze.com> wrote:
>>>
>> Hi Takashi,
>>>>
>>>> 1. Yes, it's happening on App Engine Flex.
>>>> 2. I cannot share the project because of company's rule.
>>>> 3. Some log example:
>>>>
>>>> 08:09:04.000 172.18.0.3 - - [01/Jun/2017:15:09:04 +0000] "POST
>>>> /v0/updateDeviceID HTTP/1.1" 200 86 "-" "FS/2...31 (iPhone; iOS 10.3.1;
>>>> Scale/2.00)"
>>>> 08:09:04.000[01-Jun-2017 15:09:04] WARNING: [pool app] child 53 said
>>>> into stderr: "NOTICE: PHP message: [INFO] Array"
>>>> 08:09:04.000[01-Jun-2017 15:09:04] WARNING: [pool app] child 53 said
>>>> into stderr: "("
>>>> 08:09:04.000[01-Jun-2017 15:09:04] WARNING: [pool app] child 53 said
>>>> into stderr: " [deviceId] => 6...1"
>>>> 08:09:04.000[01-Jun-2017 15:09:04] WARNING: [pool app] child 53 said
>>>> into stderr: " [userId] => 1...0"
>>>> 08:09:04.000[01-Jun-2017 15:09:04] WARNING: [pool app] child 53 said
>>>> into stderr: ")"
>>>> 08:09:04.000[01-Jun-2017 15:09:04] WARNING: [pool app] child 53 said
>>>> into stderr: ""
>>>>
>>>> 08:09:04.000 2017/06/01 15:09:04 [error] 51#0: *2273 FastCGI sent in
>>>> stderr: "PHP message: [INFO] Array
>>>> 08:09:04.000(
>>>> 08:09:04.000[deviceId] => 6...1
>>>> 08:09:04.000[userId] => 1...0
>>>> 08:09:04.000)
>>>>  08:09:04.000
>>>>
>>>> 08:09:06.359 POST 200   86B   94ms FS... /v0/updateDeviceID
>>>>
>>>> What I'm going to achieve is make all info print under the request
>>>> (last line in logging), but it prints to multiple lines in stdout/stderr
>>>> now.
>>>>
>>>>
>>>> On Wednesday, May 31, 2017 at 11:44:20 PM UTC-7, Takashi Matsuo
>>>> (Google) wrote:
>>>>
>>>>>
>>>>> Hi Yao,
>>>>>
>>>>> Few questions,
>>>>>
>>>>> Is the 499 error happening on App Engine Flex?
>>>>> Can you share the reproducible project (like zip files)?
>>>>> Can you share the logs with me? Hopefully can you invite me to your
>>>>> project as a viewer so that I can check the logs?
>>>>>
>>>>>
>>>>> On Wed, May 31, 2017 at 10:45 PM Yao Li <y...@sazze.com> wrote:
>>>>>
>>>> I fixed the project id issue for PsrBatchLogger, but it always create
>>>>>> 499 error when make api call.
>>>>>>
>>>>>>
>>>>>> On Wednesday, May 31, 2017 at 4:55:09 PM UTC-7, Yao Li wrote:
>>>>>>>
>>>>>>> I tried Monolog and it is super fast (stdout in example), but it has
>>>>>>> logging line by line and no severity, time and status code info like
>>>>>>> original gcloud logging under one request, is there any way to achieve 
>>>>>>> that
>>>>>>> with Monolog?
>>>>>>>
>>>>>>> On Tuesday, May 30, 2017 at 11:24:01 PM UTC-7, Takashi Matsuo
>>>>>>> (Google) wrote:
>>>>>>>>
>>>>>>>> Hi Yao,
>>>>>>>>
>>>>>>>> On Tue, May 30, 2017 at 9:39 PM Yao Li <y...@sazze.com> wrote:
>>>>>>>>
>>>>>>>>> > 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?
>>>>>>>>>
>>>>>>>>
>>>>>>>> Monolog?
>>>>>>>>
>>>>>>>> ```
>>>>>>>> composer require monolog/monolog
>>>>>>>> ```
>>>>>>>>
>>>>>>>> ```
>>>>>>>> <?php
>>>>>>>>
>>>>>>>> require_once __DIR__ . '/vendor/autoload.php';
>>>>>>>>
>>>>>>>> use Monolog\Logger;
>>>>>>>> use Monolog\Handler\StreamHandler;
>>>>>>>> use Monolog\Formatter\LineFormatter;
>>>>>>>>
>>>>>>>> $handler = new StreamHandler('php://stdout');
>>>>>>>> $handler->setFormatter(new LineFormatter(null, null, false, true));
>>>>>>>>
>>>>>>>> $logger = new Logger('LocalLogger', [$handler]);
>>>>>>>>
>>>>>>>> $logger->info('test');
>>>>>>>> ```
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> > 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?
>>>>>>>>>
>>>>>>>>
>>>>>>>> No you should be able to just set 'app', and it should just work. I
>>>>>>>> can not reproduce your issue. Is it possible to somehow share your 
>>>>>>>> project
>>>>>>>> so that i can repro?
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> 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.
>>>>>>>>>
>>>>>>>>
>>>>>>>> I think your app is still emitting the logs to stderr, and you are
>>>>>>>> seeing the logs on stderr which is not very well formatted.
>>>>>>>>
>>>>>>>> Once the new logger starts working, your logs will be available in
>>>>>>>> the `app` logs. Note that you need to explicitly choose `app` in the 
>>>>>>>> log
>>>>>>>> dropdown.
>>>>>>>>
>>>>>>>> -- Takashi
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> -  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 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/366a25f6-6fd1-47ae-b4fb-bb6f5cbe7982%40googlegroups.com
>>>>>>>>> <https://groups.google.com/d/msgid/google-appengine/366a25f6-6fd1-47ae-b4fb-bb6f5cbe7982%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>> .
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>> --
>>>>>>>> -- Takashi
>>>>>>>>
>>>>>>> --
>>>>>> 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/e00aad6a-b781-448c-8f7f-191737355b97%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/google-appengine/e00aad6a-b781-448c-8f7f-191737355b97%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> --
>>>>> -- Takashi
>>>>>
>>>> --
>>>> 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/e0c9ce76-9c05-4c26-957b-ee731d39b1e0%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/google-appengine/e0c9ce76-9c05-4c26-957b-ee731d39b1e0%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> -- Takashi
>>>
>> --
>> -- Takashi
>>
> --
> 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-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@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/2cc20602-993f-4801-bd8d-9ddb8b896d8a%40googlegroups.com
> <https://groups.google.com/d/msgid/google-appengine/2cc20602-993f-4801-bd8d-9ddb8b896d8a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
-- Takashi

-- 
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-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@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/CADWEYXjE17zApQbjvuKFJoxXWn7gmdxZr-qVLUNsMhEsCtqB9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to