logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin POPA <sorro...@yahoo.com>
Subject Re: Building and using log4cxx 0.9.8 on Visual Studio 2003... - UPDATE
Date Mon, 27 Nov 2006 15:01:10 GMT
Back again!

I apologize:
The NOT WORKING part from the previous email reffers actually to the version 0.9.7 of log4cxx.
We decided to try using that too, after trying with the 0.9.8 version.
(Some Monday distracting virus-bug-worm cast its bad touch on me and I forgot about 0.9.7
- sorry!).


The build output for a test project using log4cxx 0.9.8 is the following:
--------------------------------------------------------------------------------
Linking...
LoggerWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public:
__thiscall log4cxx::FileAppender::FileAppender(class log4cxx::helpers::ObjectPtrT<class
log4cxx::Layout> const &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class
std::allocator<wchar_t> > const &)" (__imp_??0FileAppender@log4cxx@@QAE@ABV?$ObjectPtrT@VLayout@log4cxx@@@helpers@1@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)
referenced in function "public: __thiscall CLoggerWindow::CLoggerWindow(class CWnd *)" (??0CLoggerWindow@@QAE@PAVCWnd@@@Z)
Debug/Encoding.exe : fatal error LNK1120: 1 unresolved externals

What we've done is simpler than in the first case (the one depicting now the usage of log4cxx
0.9.7):

we've demanded the following logging (having all the necessary paths set and the instances
declared):

CLoggerWindow::CLoggerWindow(CWnd* pParent /*=NULL*/)
    : CDialog(CLoggerWindow::IDD, pParent)
{
    m_log = Logger::getLogger("CLoggerWindow");      

    SimpleLayoutPtr sl(new SimpleLayout());

    ConsoleAppenderPtr ca(new ConsoleAppender(sl));
    FileAppenderPtr fa(new FileAppender(sl,LOG4CXX_STR("logTest.log")));
    m_log->addAppender(fa);

    LOG4CXX_INFO(m_log, "Entering application.");
}

void CLoggerWindow::OnBnClickedButton1()
{
    LOG4CXX_DEBUG(m_log, "Debug message");
}


The questions are the same from the first email:
Why is this not working? The lib seems to contain the functions mentioned in the Error message.
Why - for log4cxx version 0.9.8 from SVN - we cannot build the release version with Ant?

Many thanks!


Sorin Popa
Mobile:    +40 728 030299 


----- Original Message ----
From: Sorin POPA <sorro192@yahoo.com>
To: log4cxx Apache <log4cxx-user@logging.apache.org>
Sent: Monday, November 27, 2006 4:11:06 PM
Subject: Building and using log4cxx 0.9.8 on Visual Studio 2003...

Hello, friends!



Mi amigos and I are trying to use log4cxx in a Visual C++ project, in Visual Studio 2003.

We have built the library with Ant (following the indications in the INSTALL guide) and we
can use it now.

Still we have some questions, which may find answers here.



So, here are the facts!


What IS WORKING:

----------------------------------------------------------------------------------

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>

server.20061127.log
-----------------------
12:14:04.758 [DEBUG] main - Debug message
12:14:04.758 [INFO ] main - Info message
12:14:04.758 [WARN ] main - Warn message
12:14:04.758 [ERROR] main - Error message
12:14:04.758 [FATAL] main - Fatal error
12:14:04.758 [ERROR] main - Assertion false

This is the way we're going to use log4cxx.



What IS NOT WORKING:
----------------------------------------------------------------------------------

main.cpp
----------
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>

//#include <log4cxx/log4cxx.h>
#include <log4cxx/logger.h>
#include <log4cxx/logmanager.h>
#include <log4cxx/simplelayout.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/writerappender.h>
#include <log4cxx/fileappender.h>
#include <log4cxx/rollingfileappender.h>
#include <log4cxx/dailyrollingfileappender.h>
#include <log4cxx/helpers/stringhelper.h>

using namespace std;
using namespace log4cxx;
using namespace log4cxx::helpers;

int _tmain(int argc, _TCHAR* argv[])
{
    LoggerPtr logger (Logger::getLogger(L"main"));
    LayoutPtr  pl       (new PatternLayout(L"%d{ABSOLUTE} [%t] %level %c{2}#%M:%L - %m%n"));
    

    DailyRollingFileAppenderPtr drfa(new DailyRollingFileAppender());
    drfa->setName(L"DRFA");
    drfa->setLayout(pl);
    drfa->setDatePattern(L"yyyy-MM-dd_HH_mm_ss");
    drfa->setFile(L"OblioDRFA.log");
    drfa->activateOptions();

    logger->addAppender(drfa);

    LOG4CXX_DEBUG (logger, "Debug message");

    return 0;
}

No configuration file for log4cxx
------------------------------------

The build output is:
----------------------
Linking...
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall
log4cxx::Logger::forcedLog(class log4cxx::helpers::ObjectPtrT<class log4cxx::Level>
const &,class std::basic_string<unsigned short,struct std::char_traits<unsigned
short>,class std::allocator<unsigned short> > const &,char const *,int)" (__imp_?forcedLog@Logger@log4cxx@@QAEXABV?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@PBDH@Z)
referenced in function _wmain
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall
log4cxx::FileAppender::setFile(class std::basic_string<unsigned short,struct std::char_traits<unsigned
short>,class std::allocator<unsigned short> > const &)" (__imp_?setFile@FileAppender@log4cxx@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
referenced in function _wmain
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall
log4cxx::DailyRollingFileAppender::setDatePattern(class std::basic_string<unsigned short,struct
std::char_traits<unsigned short>,class std::allocator<unsigned short> > const
&)" (__imp_?setDatePattern@DailyRollingFileAppender@log4cxx@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
referenced in function _wmain
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall
log4cxx::PatternLayout::PatternLayout(class std::basic_string<unsigned short,struct std::char_traits<unsigned
short>,class std::allocator<unsigned short> > const &)" (__imp_??0PatternLayout@log4cxx@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
referenced in function _wmain
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static
class log4cxx::helpers::ObjectPtrT<class log4cxx::Logger> __cdecl log4cxx::Logger::getLogger(class
std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned
short> > const &)" (__imp_?getLogger@Logger@log4cxx@@SA?AV?$ObjectPtrT@VLogger@log4cxx@@@helpers@2@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
referenced in function _wmain
Debug/main.exe : fatal error LNK1120: 5 unresolved externals

We get this output, even though we have the log4cxxd.lib file included, and besides - checking
the contents of the lib - we observe the declarations that the builder announces as missing
in the message above.
We made several attempts to get something working this way, but with the same results.
We don't understand why this is happening.

We've checked many forums before posting this and tryied many times to make it work.
It seems that there were some more similar events - such messages with   unresolved external
symbol "__declspec(dllimport).... but no answers yet.

However, this is NOT the approach we'll take in using log4cxx in the project, but we would
appreciate if you can give some answers to us.


ONE MORE THING TO MENTION:
-------------------------------------
We didn't manage, using the Ant way, to build the release version of the log4cxx dll and lib.
The options for doing this are there with Ant, but we didn't get the expected result.

If you have time, please look into these.
Thanks, amigos!

I wish you all a great day!


Sorin Popa

Romania
Mobile:    +40 728 030299





 
____________________________________________________________________________________
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index






 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

Mime
View raw message