Closed xs-411 closed 2 years ago
By default, muduo logging use UTC timestamp. You can change it by calling Logger::setTimeZone(const TimeZone& tz)
int main()
{
// ...
TimeZone chinaTime(8 * 3600, "CST");
Logger::setTimeZone(chinaTime);
// ...
int main(const int argc, const char* argv[]) { for (int i = 0; i < 10; ++i) { LOG_INFO << 123; } return 0; }
root@hecs-8a9e:/data/data/bin# date Wed 20 Jul 2022 10:18:01 PM CST root@hecs-8a9e:/data/data/bin# ./ChatServer 20220720 14:18:07.208419Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208465Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208466Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208467Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208468Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208470Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208471Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208472Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208473Z 104867 INFO 1658326687 - main.cpp:11 20220720 14:18:07.208474Z 104867 INFO 1658326687 - main.cpp:11