I have tried to implement the logging in a specific file with the following code:
// pattern for the log messages
const char* pattern = "%D{%Y-%m-%d %H:%M:%S.%q} %5p: %m%n";
/* specify log pattern */
OFunique_ptr<dcmtk::log4cplus::Layout> layout(new dcmtk::log4cplus::PatternLayout(pattern));
dcmtk::log4cplus::SharedAppenderPtr logFile(new dcmtk::log4cplus::FileAppender("PrintClient.log"));
dcmtk::log4cplus::Logger logger = dcmtk::log4cplus::Logger::getRoot();
logFile->setLayout(layout);
logger.removeAllAppenders();
logger.addAppender(logFile);
logger.setLogLevel(dcmtk::log4cplus::TRACE_LOG_LEVEL);
The following errors occurred during compilation:
error C3927: "->": Ein nachstehender Rückgabetyp ist nach einem Nichtfunktionsdeklarator nicht zulässig.
error C3613: Rückgabetyp nach '"->" (Annahme: "int") fehlt
error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.
error C2371: "logFile": Neudefinition; unterschiedliche Basistypen
I tried other variable names or with OFmove, but I still get the same errors when compiling.
The error refers to the marked line.
I am using dcmtk 3.6.7 in Visual Studio 2022.
Best regards
Horst Balthasar
Logging to a specific file
Moderator: Moderator Team
-
- DCMTK Developer
- Posts: 2574
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Logging to a specific file
Did you simply forget to include the header file "dcmtk/oflog/fileap.h" for the FileAppender class? And, as described in the DCMTK Howto, you also need to use OFmove() for setting the layout.
-
- Posts: 36
- Joined: Mon, 2021-02-01, 11:32
Re: Logging to a specific file
Dear Mr Riesmeier,
the header file was included and i use the OFmove function. But I still get the same errors when compiling.
Best regards
Horst Balthasar
the header file was included and i use the OFmove function. But I still get the same errors when compiling.
Best regards
Horst Balthasar
-
- OFFIS DICOM Team
- Posts: 1534
- Joined: Tue, 2004-11-02, 17:22
- Location: Oldenburg, Germany
- Contact:
Re: Logging to a specific file
Perhaps a problem caused by the preprocessor? Is there possibly a macro named "logFile" or "setLayout" defined somewhere that causes the problem here? You might want to look at the output of the preprocessor to check this.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 1 guest