Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Crash application when trying to set setInternalDebugging or use RollingFileAppender #645

Copy link
Copy link
Open
@vhnatv

Description

@vhnatv
Issue body actions

I'm using log4cplus as a submodule in my cmake project from 2.1.x branch. It works fine in debug mode, but fails in release.
All crashes happens when I trying to setInternalDebugging (true) (on mutex initialization) or when I try use file appender
SharedAppenderPtr fileAppender(new RollingFileAppender(filePath.c_str(), 5 * 1024, 5)); (in lock function)
I tried to set in my cmake file
add_compile_definitions (LOG4CPLUS_SINGLE_THREADED=1) but this didn't help, and I can't even build the library.
The complete code of my logger is following:

         log4cplus::initialize();
        helpers::LogLog::getLogLog()->setInternalDebugging(true);

        log4cplus::tchar const fNameFrmt[] = LOG4CPLUS_TEXT("bd_%Y-%m-%d-%H-%M.log");

        log4cplus::tstring pattern = LOG4CPLUS_TEXT("[%-5p] [%d{%Y-%m-%d %H:%M:%S:%q}] [thread: %t] [%b:%L] - %m%n");

        log4cplus::helpers::Time time = log4cplus::helpers::now();

        log4cplus::tstring fileName = log4cplus::helpers::getFormattedTime(fNameFrmt, time);

        auto appFolders = GetAppFolder();

        std::filesystem::path filePath(appFolders->appFilePath());
    
        filePath.replace_filename(LOG4CPLUS_TSTRING_TO_STRING(fileName));
    
        logger_ = Logger::getRoot();
    
        SharedAppenderPtr fileAppender(new RollingFileAppender(filePath.c_str(), 5 * 1024, 5));
    
        fileAppender->setName(LOG4CPLUS_TEXT("LogFile"));

        fileAppender->setLayout(std::make_unique<PatternLayout>(pattern));

        logger_.addAppender(fileAppender);

I assume that maybe I miss something in cmakelists.txt, maybe some additional directive required or something.
In main cmakelists I just add the location of logger submodule to add_subdirectory and in my dll cmakelists txt
target_link_libraries(${PROJECT_NAME} PRIVATE log4cplusSU)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.