On Sep 26, 2008, at 4:57 PM, Wacht Woord wrote:
Dear mailing list,
I've tried to get log4cxx working under Visual studio 2008 and after
building the libs and dll it generally seemed two work. However after
some initial testing it does not:
1) When running the steps on: http://logging.apache.org/log4cxx/index.html
I get the following result:
C:\Documents and Settings\Kevin1\My Documents\Visual Studio
2008\Projects\Test\D
ebug>Test.exe
0 [0x000000e8] INFO MyApp null - Entering application.
0 [0x000000e8] DEBUG com.foo.bar null - Did it again!
0 [0x000000e8] INFO MyApp null - Exiting application.
C:\Documents and Settings\Kevin1\My Documents\Visual Studio
2008\Projects\Test\D
ebug>Test.exe
0 [0x00000ec0] INFO MyApp null - Entering application.
0 [0x00000ec0] DEBUG com.foo.bar null - Did it again!
0 [0x00000ec0] INFO MyApp null - Exiting application.
instead of the expected:
0 [12345] INFO MyApp - Entering application.
36 [12345] DEBUG com.foo.Bar - Did it again!
51 [12345] INFO MyApp - Exiting application.
The expected output was likely borrowed from the log4j documentation.
The first column is the number of milliseconds and it looks like
log4cxx does all three log requests within 1 ms. The values would
vary depending on processors, system load etc.
The number in the brackets is the thread name of the thread making the
logging request. That concept exists in Java, but not really in most
OS's, so the handle to the current thread is output. That value would
vary between invocations. The values that appear normal for Win32,
for Win64 they would be twice as long.
The other potential that a null NDC results in "null" being output
instead of the "" shown in the sample output. I'll need to double
check what log4j does in this situation and make sure that log4cxx
conforms.
Other than the last item, it just seems to be only an issue with the
documentation.
2) when expanding the logging with additional Appenders the result
is the same.
3) I tried using NDC calls from trivial.cpp:
NDC::push("trivial context"); and NDC::pop();
Again other than a possible problem with the NDC rendering, everything
looks as I'd expect. It is just the getting started guide looks like
it needs to be updated to more reasonable sample output.
another test-app you provide and get illegal memory violations.
Please let me know which one. All the sample apps should be built and
run during the ant build script, so either the app you are having
problems with got left out of the build or there is something about
the way you are building it.
Basically I just want a logger which logs to a file. It doesn't have
to be anything fancy.
Could you help me out?
This section of the documentation walks you from explicit
initialization to default initialization (that is attempting to find
log4cxx.properties, log4cxx.xml, log4j.properties or log4j.xml in the
working directory and loading it). Using default initialization is
probably by far the most common usage and the organization of the
document could likely be improved to cover the most common use cases
first instead of the simplest.
Also, it is probably better form to avoid putting the logger into the
header files. That is borrow a pattern from log4j that can be done in
a better way. Instead do something like:
// file bar.cpp
#include "com/foo/bar.h"
#include <log4cxx/logger.h>
using namespace com::foo;
namespace {
log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("com.foo.bar"));
}
void Bar::doIt() {
LOG4CXX_DEBUG(logger, "Did it again!")
}