You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Jing Yang <jy...@jbmanagement.com> on 2006/03/03 18:52:28 UTC
unexpected console output format
When the example MyApp(similar in short introduction) was run with config
file "log4j.properties", the unexpected output was as below:
debug message
info message
When the MyApp was run without config file, unexpected was some like:
debug message
3 [8192} DEBUG MyApp - debug message
info message
4 {8192] INFO MyApp -info message
The running environment:
RedHat 8.0
Log4cxx.97
Appreciate your help !
The source code(MyApp.cpp) and config(log4j.properties) file is listed here
for ref
MyApp.cpp
#include <log4cxx/config.h>
// include log4cxx header files.
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/xml/domconfigurator.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
// Define a static logger variable so that it references the
// Logger instance named "MyApp".
int main(int argc, char **argv)
{
int result = EXIT_SUCCESS;
try
{
if (argc > 1)
{
// BasicConfigurator replaced with
PropertyConfigurator.
PropertyConfigurator::configure(argv[1]);
}
else
{
BasicConfigurator::configure();
}
LoggerPtr logger= Logger::getLogger(_T("MyApp"));
logger->info(_T("Entering application."));
logger->info(_T("Exiting application."));
}
catch(Exception&)
{
result = EXIT_FAILURE;
}
return result;
}
log4.properties:
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Re: unexpected console output format
Posted by Andreas Fester <af...@apache.org>.
Hi,
please use log4cxx 0.9.8, if anyhow possible. A daily
distribution tarball and binaries are available at
http://www.littletux.net/log4cxx/
I tried your application with it, and the output
without the property file is
0 [0x2aaaad76b850] INFO MyApp null - Entering application.
1 [0x2aaaad76b850] INFO MyApp null - Exiting application.
and with the property file its
1 [0x2aaaad76b850] INFO MyApp null - Entering application.
1 [0x2aaaad76b850] INFO MyApp null - Exiting application.
Regards,
Andreas
Jing Yang wrote:
> When the example MyApp(similar in short introduction) was run with config
> file "log4j.properties", the unexpected output was as below:
[...]