Simple question on OFlog usage

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
kattabomane
Posts: 40
Joined: Tue, 2005-02-01, 22:53

Simple question on OFlog usage

#1 Post by kattabomane » Wed, 2017-04-05, 16:31

Hello,

I am currently following the FAQ for using OFlog.

FAQ
http://support.dcmtk.org/docs/mod_oflog.html

My code is a simple as below :

Code: Select all

OFLogger logger = OFLog::getLogger("log4cplus_configure.ini");
OFLOG_DEBUG(logger, "DCMTK version " << OFFIS_DCMTK_VERSION);
And my configurations file (log4cplus_configure.ini) is as below :

Code: Select all

###################################
########Define log Levels##########
###################################

#All classes - except those in log4cplus.logger.* - use DEBUG level to print information on file
log4cplus.rootLogger=DEBUG, MyFileAppender

#For MemoryCheck class I need to inspect all the details, and I want print information even to the console
log4cplus.logger.MemoryCheck=TRACE, MyConsoleAppender

#For database stuff, I don't need to logging everything, it's enough printing only errors!
log4cplus.logger.DatabaseOperations=ERROR

###################################
########Define the Appenders#######
###################################

#MyConsoleAppender:
log4cplus.appender.MyConsoleAppender=log4cplus::ConsoleAppender
log4cplus.appender.MyConsoleAppender.layout=log4cplus::PatternLayout
log4cplus.appender.MyConsoleAppender.layout.ConversionPattern=[%-5p][%d] %m%n

#MyFileAppender
log4cplus.appender.MyFileAppender=log4cplus::RollingFileAppender
log4cplus.appender.MyFileAppender.File=D:\Z\Testdcmtk.log
log4cplus.appender.MyFileAppender.MaxFileSize=16MB
log4cplus.appender.MyFileAppender.MaxBackupIndex=1
log4cplus.appender.MyFileAppender.layout=log4cplus::PatternLayout
log4cplus.appender.MyFileAppender.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n
I can't figure out why there is no log produced.
I have no linking error using dcmtk.

Thanks for your help

Kattabomane

J. Riesmeier
DCMTK Developer
Posts: 2008
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Simple question on OFlog usage

#2 Post by J. Riesmeier » Fri, 2017-04-07, 17:15

Seems that you are mixing up logger name and logging configuration filename (you use "log4cplus_configure.ini" for both). Where do you load the configuration file?

kattabomane
Posts: 40
Joined: Tue, 2005-02-01, 22:53

Re: Simple question on OFlog usage

#3 Post by kattabomane » Sat, 2017-04-08, 10:51

Hello,
Yes, this is the issue.
But how to configure OFLogger with a configuration file so as to be able to change patterns or whatever when necessary.
Could you please give some hints ? There no info about under the respective FAQ.

Thanks in advance,
Regards,
Kattabomane.

J. Riesmeier
DCMTK Developer
Posts: 2008
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Simple question on OFlog usage

#4 Post by J. Riesmeier » Sat, 2017-04-08, 20:40

Looking into the implementation of OFLog::configureFromCommandLine() might help.

kattabomane
Posts: 40
Joined: Tue, 2005-02-01, 22:53

Re: Simple question on OFlog usage

#5 Post by kattabomane » Sun, 2017-04-09, 15:40

Hello,

Thanks for the hint.

Figured out how to configure via a configuration file :

Code: Select all

 
log4cplus::PropertyConfigurator::doConfigure("D:/Test/log4cplus_configure.ini");
OFLogger logger = OFLog::getLogger("MyFileAppender");
OFLOG_DEBUG(logger, "DCMTK version " << OFFIS_DCMTK_VERSION);
Thanks.

Kattabomane.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest