Am 23.08.2013 21:13, schrieb Olaf Radicke:
> Hi!
>
> In the last days I gather some experience with the topic "logging".
> I'm not sure, but I think cxxtools/log is not all the time the best choice.
> In an older mail I wrote about my problems with cxxtools/log. The main thing
> is,
> that I can`t configure the logging level in C++-Code directly. The only way is
> the support of a deserializer class and this is not so comfortable. So I had a
> look on POCO and boost.
>
> The boost-Lib has a logging solution with many features. It`s very well
> documented: http://boost-log.sourceforge.net/libs/log/doc/html/index.html
> But the logging part of boost is too young for the most linux distributions
> and it has not all ready packets.
>
> The POCO-Lib has a very feature rich logging solution too and a very fine
> documentation:
> * http://pocoproject.org/docs/package-Foundation.Logging-index.html
> * http://pocoproject.org/slides/110-Logging.pdf
> And the important point: It is a part of the most linux distributions (i
> think).
>
> Now actually, I want recommend that if the tntnet user need more features for
> logging tasks/cases, than it is best practice to use POCO logger and not
> cxxtools. Do you agree with me?
>
> best regards
>
> Olaf
I don't agree at all. What do you expect people to think about tntnet if
you say: hey, we have a logging library but if you do something good,
don't use it.
I agree, that there are other logging libraries, which have more
features than cxxtools logging and are better documented. Feel free to
use them if you want to.
Cxxtools logging follows a philosophy. Logging must be lightweight and
quick and easy to use.
I looked at the slides of poco logging. One of the most important
features in cxxtools logging is easy formatting of messages using
std::ostream. Poco offers a solution but it is ugly. Look at that:
Poco::Logger& logger = Logger::get("TestLogger");
Poco::LogStream lstr(logger);
lstr << "The value of a is " << a << std::endl;
Compared to cxxtools:
log_debug("The value of a is " << a);
At the top of the file you will find:
log_define("TestLogger")
There are several problems with the poco solution. The first thing is,
that you need 3 lines of code just to log something. I don't like it.
But what is worse is, that the formatting takes place always. If the
logging for "TestLogger" is disabled, the operator<< will format the
value of "a" into the stream and throw the result away. Formatting of
log messages takes time. And this is absolutely unacceptable to take the
time just to throw the message away.
In cxxtools log_debug is a macro, which first checks, if logging is
enabled. If not, the message is not formatted. It is far faster.
Another point is, that cxxtools logging is used by tntnet, tntdb and of
course cxxtools itself already. If you for example encounter problems
accessing the database, enable logging for the category "tntdb" and you
get plenty of information what is going wrong here.
Configuring cxxtools logging may be improved. We already added the
possibility to use the serialization framework to do it, so that you can
configure logging using xml, properties or json. That is really great,
that we can integrate the configuration into our main configuration file
of our application.
Runtime configuration is not really supported. I have never needed it,
since I enable logging only when I have some problems with the
application. Then it is really no problem to restart the application.
You mentioned, that you want to have a command line argument -v to
enable logging. But a logging library has not only "yes" or "no" but you
can configure log levels per category. And this is a great feature, we
use every day in our projects. Just enabling is not really good enough.
Tommi
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general