yii2: problem with the size of the log[yii2/log/FileTarget]

What steps will reproduce the problem?

The log is full and concurrent

What is the expected result?

The log should be full

What do you get instead?

some logs are too small

image

Additional info

Q A
Yii version 2.0.45
PHP version 7.2.6
Operating system windows

same as #19079

hello, I’m back again, after our testing, The problem is due to rotateFiles and concurrency

config

'log' => [
	'targets' => [
		[
			'class' => 'yii\log\FileTarget',
			'categories' => ['open'],
			'logVars' => [],
			'maxFileSize' => 100, //for better display of errors
			'maxLogFiles' => 5,
			'logFile' => '@root/runtime/logs/open.log',
		]
	],
],

code

$request = Yii::$app->request;
$header = $request->getHeaders();
$get = $request->get();
$body = $request->bodyParams;
$method =  $request->method;
Yii::info([
	'header' => $header,
	'get' => $get,
	'body' => $body,
	'method' => $method,
], 'open');

test with ab

ab -n1000 -c10 http://example.com/path1/path2

You will see that some logs are very small

By the way, I don’t think it’s a good idea to attach an application log when logvar is not empty, preferably something that can be controlled.

'logVars' => ['_GET', '_POST'],

// will hava
... category: application ....

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 33 (21 by maintainers)

Commits related to this issue

Most upvoted comments

See the linked SO answer that I linked in my last comment above. $would_block is basically just a flag that indicates that something is seriously going wrong when accessing the lock file. This is not related to our problem.

And we already use the default of blocking mode. That’s fine because we want a 2nd process to wait a (hopefully) short amount of time until the 1st process will release the lock. LOCK_NB is not what we want.