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

several files logging #605

Closed
FarafontovDmitriy opened this issue Feb 8, 2018 · 3 comments
Closed

several files logging #605

FarafontovDmitriy opened this issue Feb 8, 2018 · 3 comments

Comments

@FarafontovDmitriy
Copy link

I need to log into several files. I do it like this
`
#ifndef ELPP_THREAD_SAFE
#define ELPP_THREAD_SAFE
#define ELPP_FORCE_USE_STD_THREAD
#endif
....................................

logger = el::Loggers::getLogger(loggeId);
loggerData = el::Loggers::getLogger(loggerDataId);

            ss << " * GLOBAL:\n"
		<< "    FORMAT              =	%datetime{%d/%M/%Y %h:%m:%s,%g} %level %msg\n"
		<< "	TO_FILE				=	true\n"
		<< "	TO_STANDARD_OUTPUT	=	false\n"
		<< "	FILENAME			=	" << logPath << logName << "\n"
		<< "	MAX_LOG_FILE_SIZE	=   " << logSize;

	logConf.parseFromText(ss.str());

	ss.str("");
	ss << " * GLOBAL:\n"
		<< "    FORMAT              =	%datetime{%d/%M/%Y %h:%m:%s,%g} %level %msg\n"
		<< "	TO_FILE				=	true\n"
		<< "	TO_STANDARD_OUTPUT	=	false\n"
		<< "	FILENAME			=	" << logPath << "data_" << logName << "\n"
		<< "	MAX_LOG_FILE_SIZE	=   " << logSize;

	logDataConf.parseFromText(ss.str());

el::Loggers::reconfigureLogger(logger, logConf);
el::Loggers::reconfigureLogger(loggerData, logDataConf);

...........................
CLOG(INFO, loggeId.c_str()) << message;
CLOG(INFO, loggerDataId.c_str()) <<message;
`
As a result, some entries from one log file fall into another and the application crashes (Access violation). What am I doing wrong ?

@BigTony
Copy link

BigTony commented Feb 8, 2018

If you are logging in multiple threads than u are probably facing same issue #580. If so I suggest close this and continue there.

@FarafontovDmitriy
Copy link
Author

Ok!

@abumq
Copy link
Owner

abumq commented Apr 2, 2018

YOU SHOULD NOT DEFINE MACRO IN YOUR CODE AS SOME MACROS ARE USED IN SOURCE FILE (easylogging++.cc) AS WELL. THIS IS COMMON CAUSE OF FAILURE
e.g, ELPP_THREAD_SAFE or ELPP_FORCE_USE_STD_THREAD

Always use compiler options

@abumq abumq closed this as completed Apr 2, 2018
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