Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: logging entry does not contain timestamps? #304

Open
yxiang92128 opened this issue Nov 7, 2019 · 5 comments
Open

Question: logging entry does not contain timestamps? #304

yxiang92128 opened this issue Nov 7, 2019 · 5 comments
Assignees
Labels

Comments

@yxiang92128
Copy link

Hi,

I am using a file_backend in boost to dump the azure logs with format specified as below: boost::log::keywords::format = "%UTCTimeStamp% (%TimeStamp%) [%ThreadID%]: %Message%",

However the messages shown in the log don't seem to contain timestamp/thread number:
59B8CCCB-B782-418A-94BD-668C5C521B48 : Failed request ID =
59B8CCCB-B782-418A-94BD-668C5C521B48 : Exception thrown while processing response: Not Found
59B8CCCB-B782-418A-94BD-668C5C521B48 : Retry policy did not allow for a retry, so throwing exception: Not Found
267F2550-8563-4DCA-9CAD-3306199FEF39 : Exception thrown while processing response: Error in SSL handshake

I can't figure out what I've done wrong here. Can you please help?

Thanks,

Yang

@yxiang92128 yxiang92128 changed the title Question: logging entries does not contain timestamps? Question: logging entry does not contain timestamps? Nov 7, 2019
@Jinming-Hu Jinming-Hu self-assigned this Nov 8, 2019
@Jinming-Hu
Copy link
Member

I'm going to look into this issue.

@Jinming-Hu
Copy link
Member

@yxiang92128 Did you ever call boost::log::add_common_attributes() which registers attributes like TimeStamp, ProcessID, ThreadID.

@yxiang92128
Copy link
Author

@JinmingHu-MSFT
see attached test code. I tried add_common_attributes before and after add_sink call and neither worked. Any hints?

Thanks,

Yang
test_azure.cpp.txt
compile_test_azure.txt

@Jinming-Hu
Copy link
Member

Jinming-Hu commented Nov 12, 2019

@yxiang92128 Maybe you should setup formatter or register attributes by yourself instead of calling add_common_attributes for self-defined sink? I'm not sure, the boost::log stuff is kind of complex.

The following easy log init code works for me.

boost::log::add_file_log
(
    boost::log::keywords::file_name = "log.txt",
    boost::log::keywords::format = "%UTCTimeStamp% (%TimeStamp%) [%ThreadID%]: %Message%"
);
boost::log::add_common_attributes();

And you can have a look at boost/log/utility/setup/file.hpp::add_file_log, it does something more than just initialize a backend and a sink and add the sink to core.

@Jinming-Hu
Copy link
Member

We're going to close this issue because of inactivity, feel free to reopen it if you have any further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants