logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit Gokani <amit.gok...@ketech.com>
Subject RE: Problems building with MinGW
Date Fri, 27 Jun 2008 14:49:58 GMT

Hi,

I am new to this forum and was looking an example of code that uses the log4cxx libraries.
I am running a VC application as a service that needs to generate a log file with debug messages
in a particular directory.

I have built the log4cxxx libraries and included them in my application. The code compiles
fine albeit lots of warning messages and then tried to implement the below worked example
but all that happens is that the application crashes.

Thanks,
Amit

main.cpp
----------
#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/helpers/exception.h>
#include <iostream>

int main(int argc, char **argv)
{
    try
    {
        log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("main"));
        log4cxx::xml::DOMConfigurator::configure("log4cxx.xml");
        LOG4CXX_DEBUG(logger, "Debug message");
        LOG4CXX_INFO(logger, "Info message");
        LOG4CXX_WARN(logger, "Warn message");
        LOG4CXX_ERROR(logger, "Error message");
        LOG4CXX_FATAL(logger, "Fatal error");
        LOG4CXX_ASSERT(logger, 1 == 2, "Assertion false");
        return 0;
    }
    catch (const log4cxx::helpers::Exception & exception)
    {
        std::cerr << "log4cxx::helpers::Exception caught - original message: "
<< exception.what() << std::endl;
        return 1;
    }
}


log4cxx.xml
-------------
<?xml version="1.0" encoding="UTF-8"?>
http://jakarta.apache.org/log4j/' debug="false">
    <appender name="DRFA" class="org.apache.log4j.rolling.RollingFileAppender">
        <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
            <param name="FileNamePattern" value="C:\server.%d{yyyyMMdd}.log"/>
        </rollingPolicy>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{HH:mm:ss.SSS} [%-5p]
%c{1} - %m%n"/>
        </layout>
        <param name="Append" value="true"/>
    </appender>
    <root>
        <level value="DEBUG"/>
        <appender-ref ref="DRFA"/>
    </root>
</log4j:configuration>


-----Original Message-----
From: Olivier Beaton [mailto:olivier.beaton@gmail.com]
Sent: 27 June 2008 15:19
To: Log4CXX User
Subject: Re: Problems building with MinGW

Not to worry Dale,  there are already instructions for building with VC
http://logging.apache.org/log4cxx/building/vstudio.html
and they work rather well, I used them just the other day (took about
5 minutes to build log4cxx).

The project I am involved in is built both on linux and on windows,
using gcc g++ mingw on windows, and gcc g++ on linux.  Our IDE is
eclipse CDT on both operating systems.  We only use cross-platform
libraries, like boost, xercesc, and hoping to use log4cxx.

So there are advantages to using a non-windows specific toolchain, the
problem here was that apr was broken at the moment for the windows
version of that toolchain (mingw).

Olivier Beaton

Mime
View raw message