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

file loggers don't produce any output in the file #82

Closed
p0fi opened this issue Apr 23, 2015 · 7 comments
Closed

file loggers don't produce any output in the file #82

p0fi opened this issue Apr 23, 2015 · 7 comments

Comments

@p0fi
Copy link

p0fi commented Apr 23, 2015

I've tried to create a file logger by using this line:

auto MainDebug = spdlog::rotating_logger_mt("file_logger", "logs/mylogfile", 1048576 * 5, 3);

then i do write some log outputs with this line:

MainDebug->trace("some text");

the log file is created, but it always have a 0 bytes size and therefore nothing in it.

Using the latest version from the master branch.

@xaqq
Copy link
Contributor

xaqq commented Apr 23, 2015

I suppose this has to do with the default log level.

On Thu, Apr 23, 2015 at 10:57 AM, p0fi notifications@github.com wrote:

I've tried to create a file logger by using this line:

auto MainDebug = spdlog::rotating_logger_mt("file_logger",
"logs/mylogfile", 1048576 * 5, 3);

then i do write some log outputs with this line:

MainDebug->trace("some text");

the log file is created, but it always have a 0 bytes size and therefore
nothing in it.

Using the latest version from the master branch.


Reply to this email directly or view it on GitHub
#82.

Kapp Arnaud - Xaqq

@p0fi
Copy link
Author

p0fi commented Apr 23, 2015

This is interestingly producing output in the file:

auto rotating = make_shared<spdlog::sinks::rotating_file_sink_mt> ("logs/testlog", "log", 1024*1024, 5, false);
auto file_logger = make_shared<spdlog::logger>("my_logger", rotating);
file_logger->info("Hello spdlog {} {} {}", 1, 2, "three");

If try the exact same pattern with a logger with multiple sinks like this:

std::vector<spdlog::sink_ptr> sinks;
sinks.push_back(make_shared<spdlog::sinks::stdout_sink_mt>());
sinks.push_back(make_shared<spdlog::sinks::rotating_file_sink_mt> ("logs/testlog", "log", 1024*1024, 5, false));
auto file_logger = make_shared<spdlog::logger>("my_logger", begin(sinks), end(sinks));

file_logger->info("Hello spdlog {} {} {}", 1, 2, "three");

it only gives me the output in the console, nothing in the file,...the file is created but nothing is written in it!

@p0fi
Copy link
Author

p0fi commented Apr 23, 2015

strange, this which was working for me described in the last comment stopped to work completely.

0 output into the file

what could be wrong?

@gabime
Copy link
Owner

gabime commented Apr 23, 2015

Might be that the logger didnt flushed yet into the disk.
If you set the last param to true it will flush in every write(but will be much slower of course)

@p0fi
Copy link
Author

p0fi commented Apr 24, 2015

Oh, well this really seems to fix the problem, thanks!
Maybe its worth mentioning it in the wiki?
And is there a way to manually flush it to the disk on demand?

@gabime
Copy link
Owner

gabime commented Apr 24, 2015

I agree. The wiki should mention it.

No way to tell it to flush.
In older versions there was an integer instead of tne boolean to indicate the flush interval (e.g 4 to flush every 4 log calls), But i replaced with bool since it is simpler API..

Maybe i should return this feature if there is popular demand for it:)

@p0fi p0fi closed this as completed Apr 24, 2015
@gabime
Copy link
Owner

gabime commented Apr 24, 2015

Added a wiki page about it..

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

No branches or pull requests

3 participants