[IGSTK-Developers] log4cxx - About
Bitter, Ingmar (NIH/CC/DRD)
IBitter at cc.nih.gov
Thu Feb 24 19:35:26 EST 2005
Hi Luis,
I like log4cxx. I just browsed the website and the code.
One thing is missing that I usually also like to see, which is the cvs ID of
the src file. I added it in to our logger macro:
At the top of each .cpp file:
static char const cvsId[] = "$Header: .../misc/MemoryHandler.cpp,v 1.2
2004/08/30 14:32:07 ibitter Exp $";
the log macros:
/// something is definitely wrong, but a reasonable fallback solution exist
and will be used
#define LogWrn(msg) if (LogMsg::getTheWeakestLoggedMsgLevel() <=
LogMsg::logWarning ) LogMsg(LogMsg::logWarning, msg, __FILE__,
__LINE__, cvsId)
/// general progress information, useful for program users/clients
#define LogFyi(msg) if (LogMsg::getTheWeakestLoggedMsgLevel() <=
LogMsg::logInformation) LogMsg(LogMsg::logInformation, msg, __FILE__,
__LINE__, cvsId)
/// detailed information, useful for any programmer examining the log
#define LogDbg(msg) if (LogMsg::getTheWeakestLoggedMsgLevel() <=
LogMsg::logDebug ) LogMsg(LogMsg::logDebug, msg, __FILE__,
__LINE__, cvsId)
/// very verbose information, only for debugging of current problem, except
for flow of control should not be part of checked in version
#define LogTmp(msg) if (LogMsg::getTheWeakestLoggedMsgLevel() <=
LogMsg::logTemporary ) LogMsg(LogMsg::logTemporary, msg, __FILE__,
__LINE__, cvsId)
However, if one would use subversion, then a single log entry at the
beginning of program execution with the file version number stamp at last
checkout time would be sufficient to uniquely identify which version of each
source file was used during compilation of the program and log4cxx could be
used without modification.
One other thing I do differently: My exceptions automatically log what is
wrong, again done through a macro:
/// throws an exception with a LogMsg exception object that logs to the
console and a log file what went wrong where
#define throwException(msg) throw Exception(LogMsg(LogMsg::logError, msg,
__FILE__, __LINE__, cvsId))
Finally, their design is for coexistence of multiple loggers that each can
have different levels. I am not sure if that much complexity is needed.
What would be a good use case in which one needs multiple loggers? I have
one globally set logging level and global logger object, hence to use it you
only need to call global static functions and do not have to worry about
getting named logging objects. If I have a particular function that needed
more detailed analysis, I create dummy object
LogMsg::CurrentScopeWeakestMsgLevel dummyObject(LogMsg::logDebug);
At the beginning of the function and its destructor will reset the log level
to the previous state upon function exit. This then has effect for all
dependent function calls and helps a lot in reducing console/log file
clutter.
So dependent on the expected use cases log4cxx may be needed, or something
simpler like my attached logger + exception classes may suffice.
Ingmar Bitter, PhD
Staff Scientist
NIH, CC, DRD, CIPS
email: ibitter at nih.gov
Tel: 301.435.2155
-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: Thursday, February 24, 2005 2:10 PM
To: igstk-developers at public.kitware.com; Kevin Gary
Subject: [IGSTK-Developers] log4cxx - About
As we discussed at the tcon, there is some interest on
the ITK community for adding a logger class to ITK.
They are looking at the log4j and log4cxx libraries as
Sohan proposed some time ago.
http://logging.apache.org/
The link to log4cxx is:
<http://logging.apache.org/log4cxx/>
The link to log4j is:
http://logging.apache.org/log4j/docs/
The main concern here is the license of the library:
The Apache License is at:
http://www.apache.org/licenses/LICENSE-2.0.txt
Comments about it are at:
http://www.apache.org/foundation/licence-FAQ.html
A detailed discussion of the "Apache" license is
available at:
http://www.apache.org/licenses/
Luis
_______________________________________________
IGSTK-Developers mailing list
IGSTK-Developers at public.kitware.com
http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-developers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Exception.cpp
Type: application/octet-stream
Size: 375 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/igstk-developers/attachments/20050224/41fe23e4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Exception.h
Type: application/octet-stream
Size: 735 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/igstk-developers/attachments/20050224/41fe23e4/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LogMsg.cpp
Type: application/octet-stream
Size: 8315 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/igstk-developers/attachments/20050224/41fe23e4/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LogMsg.h
Type: application/octet-stream
Size: 5534 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/igstk-developers/attachments/20050224/41fe23e4/attachment-0003.obj>
More information about the IGSTK-Developers
mailing list