Open bscheshirwork opened 7 years ago
So... I can get a message time with php timezone instead of a yii2 application default timezone in all cases?
have you read the docs of defaultTimeZone
? It is used to determine the timezone of values in the database, which are formatted and converted to timeZone
. So setting defaultTimezone should not affect log formatting at all.
@cebe I tell about update docs...
It is used to determine the timezone of values in the database
I read guide formatting. I don't see "database" (without ICU database)
I read guide log
I don't see anything about timezone. Only one time timestamp
in Message Formatting
.
I think can be add to example settings additional line
return [
// the "log" component must be loaded during bootstrapping time
'bootstrap' => ['log'],
// the "log" component process messages with timestamp. Set php timezone to create correct timestamp
'timeZone' => 'America/Los_Angeles',
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\DbTarget',
'levels' => ['error', 'warning'],
],
[
'class' => 'yii\log\EmailTarget',
'levels' => ['error'],
'categories' => ['yii\db\*'],
'message' => [
'from' => ['log@example.com'],
'to' => ['admin@example.com', 'developer@example.com'],
'subject' => 'Database errors at example.com',
],
],
],
],
],
];
I have
\Yii2::$app->formatter->defaultTimeZone
not equalphp
timezoneI can see framework/log/Target.php#L273-L274 framework/log/Target.php#L119
So... I can get a message time with
php
timezone instead of a yii2 application default timezone in all cases?I expect a time value in log is native for yii2 application if
\Yii2::$app->formatter->defaultTimeZone
is set.The yii\i18n\Formatter|formatter is a build-in component, any apps can use it, right?
But i must use additional settings - yii\base\Application::timeZone|timeZone
I think need tell about this differences as a note in the
formatter
andlog
chapters.Additional info