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 Jo...@kisters.de on 2007/09/25 10:48:59 UTC

Getting Started under VS2005

Hello!
I'm new to C++ and am trying to get log4cxx to run under a little console 
test application written with Visual Studio 2005 C++
Can you please tell me what to add where in order to make your examples 
under http://logging.apache.org/log4cxx/manual.html
work?
With Regards,
Johannes Frank

Re: Getting Started under VS2005

Posted by Curt Arnold <ca...@apache.org>.
On Sep 27, 2007, at 6:49 AM, Johannes.Frank@kisters.de wrote:

>
> Great Thanks to you both!
>
> With your help, I managed to get the first example of log4cxx running.
> the Second example (which should take an optional filename as  
> argument to read the config from) Fails, because the method wants a  
> File handler rather than a chararray)
> Solution was as follows:
>         File* file = new File("test.txt");
>                 PropertyConfigurator::configure(*file);
>
> with this configuration, It reads the file test.txt from the  
> projects root directory and interpretes it correctly, allowing me  
> to configure appenders inside the file "test.txt"
> At Last I can see a dim light at the horizon :)
> Thanks again :)
> Greetings,
> Johannes Frank


There is no need to dynamically allocate File.  You could do:

File file("test.txt");
PropertyConfigurator::configure(file);

or

PropertyConfigurator::configure(File( "test.txt"));

log4j does have a configure(String) method, so it would be reasonable  
to add a configure(const std::string&) and configure(const  
std::wstring&) methods to PropertyConfigurator.



RE: Getting Started under VS2005

Posted by Jo...@kisters.de.
Great Thanks to you both!

With your help, I managed to get the first example of log4cxx running. 
the Second example (which should take an optional filename as argument to 
read the config from) Fails, because the method wants a File handler 
rather than a chararray)
Solution was as follows:
        File* file = new File("test.txt");
                PropertyConfigurator::configure(*file);

with this configuration, It reads the file test.txt from the projects root 
directory and interpretes it correctly, allowing me to configure appenders 
inside the file "test.txt"
At Last I can see a dim light at the horizon :)
Thanks again :)
Greetings,
Johannes Frank

RE: Getting Started under VS2005

Posted by "Wilfong, Paul" <pa...@ngc.com>.
Iwan's steps also are good for VS2003, with minor tweaks due to
differences in the two versions.  For example, in VS2003, you get to the
project properties under the Project pull-down menu.

 

I'd also recommend to have VS automatically copy the dll to your
executable location, by going to the project properties, Build
Events->Post-Build Event, and putting the copy command into the Command
Line field.  (This is for VS2003 - I hope VS2005 is similar).

 

That way, if you rebuild the log4cxx dll, you don't have to remember to
copy it to the execution location.  I usually forget, and then if I try
to use the debugger in my application to step into the log4cxx code, the
message "There is no source code available for the current location"
pops up.


________________________________

From: Iwan Tomlow [mailto:iwan.tomlow@seagha.com] 
Sent: Wednesday, September 26, 2007 12:20 AM
To: Log4CXX User
Subject: RE: Getting Started under VS2005


Only thing you need to do is tell the linker your project will be
dependent of the log4cxx-library.
 
In VS2005, this can be done via Project Properties, go to Configuration
Properties > Linker > Input, en add the log4cxx-library in the
"Additional Dependencies" option.
For debug-build of your project, you will want to add "log4cxxd.lib",
for release-build "log4cxx.lib".
 
Linker must of course be able to find these files, so either make it a
full path or add the lib-directory to the general search-path via menu
Tools > Options > Projects and Solutions > VC++ Directories.
Select "Library files" as "Show directories for:", and add the path to
your log4cxx-build (something like "C:\log4xx-0.10.0\lib").
 
You'll probably also want to add "C:\log4cxx-0.10.0\include" or the
likes in the "Include files" search path here.
 
Finally, just add appropriate includes for log4cxx.h etc. as in the
examples, and make sure the actual log4cxx.dll (or log4cxxd.dll) are
present at the same location as your .exe, or can be located via your
Windows PATH environment.
 
Hope this helps

________________________________

From: Johannes.Frank@kisters.de [mailto:Johannes.Frank@kisters.de] 
Sent: woensdag 26 september 2007 8:53
To: Log4CXX User
Subject: RE: Getting Started under VS2005



Thank you for your quick answer. However, this was not what I meant. I
found this post already (bless merc, that is) and managed to compile
log4cxx using his given project file. 
The problem I have now is that I have absolutely no idea on how to
include the compiled dll into my own project because I never worked with
Visual C++ before. 
I tried and clicked around a little (I use C# a lot more often than C++)
but with no result so far. 
If someone could help me out with this problem, I would be happy ;-) 

Greets, 
Johannes Frank 

RE: Getting Started under VS2005

Posted by Iwan Tomlow <iw...@seagha.com>.
Only thing you need to do is tell the linker your project will be
dependent of the log4cxx-library.
 
In VS2005, this can be done via Project Properties, go to Configuration
Properties > Linker > Input, en add the log4cxx-library in the
"Additional Dependencies" option.
For debug-build of your project, you will want to add "log4cxxd.lib",
for release-build "log4cxx.lib".
 
Linker must of course be able to find these files, so either make it a
full path or add the lib-directory to the general search-path via menu
Tools > Options > Projects and Solutions > VC++ Directories.
Select "Library files" as "Show directories for:", and add the path to
your log4cxx-build (something like "C:\log4xx-0.10.0\lib").
 
You'll probably also want to add "C:\log4cxx-0.10.0\include" or the
likes in the "Include files" search path here.
 
Finally, just add appropriate includes for log4cxx.h etc. as in the
examples, and make sure the actual log4cxx.dll (or log4cxxd.dll) are
present at the same location as your .exe, or can be located via your
Windows PATH environment.
 
Hope this helps

________________________________

From: Johannes.Frank@kisters.de [mailto:Johannes.Frank@kisters.de] 
Sent: woensdag 26 september 2007 8:53
To: Log4CXX User
Subject: RE: Getting Started under VS2005



Thank you for your quick answer. However, this was not what I meant. I
found this post already (bless merc, that is) and managed to compile
log4cxx using his given project file. 
The problem I have now is that I have absolutely no idea on how to
include the compiled dll into my own project because I never worked with
Visual C++ before. 
I tried and clicked around a little (I use C# a lot more often than C++)
but with no result so far. 
If someone could help me out with this problem, I would be happy ;-) 

Greets, 
Johannes Frank

RE: Getting Started under VS2005

Posted by Jo...@kisters.de.
Thank you for your quick answer. However, this was not what I meant. I 
found this post already (bless merc, that is) and managed to compile 
log4cxx using his given project file.
The problem I have now is that I have absolutely no idea on how to include 
the compiled dll into my own project because I never worked with Visual 
C++ before.
I tried and clicked around a little (I use C# a lot more often than C++) 
but with no result so far. 
If someone could help me out with this problem, I would be happy ;-)

Greets,
Johannes Frank

RE: Getting Started under VS2005

Posted by "Wilfong, Paul" <pa...@ngc.com>.
The best thing that I found to start out with was a website referred to
in the log4cxx mailing list:
http://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/200705.mbo
x/%3c10834453.post@talk.nabble.com%3e
<BLOCKED::http://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/
200705.mbox/<10...@talk.nabble.com>> 
 
This post references a blog at http://www.dreamcubes.com/blog/?itemid=43
that discusses building log4cxx using Visual Studio 2005.  I was able to
use it as a guide to get a build going under Visual Studio 2003.
 
Bless you merc!

________________________________

From: Johannes.Frank@kisters.de [mailto:Johannes.Frank@kisters.de] 
Sent: Tuesday, September 25, 2007 1:49 AM
To: log4cxx-user@logging.apache.org
Subject: Getting Started under VS2005



Hello! 
I'm new to C++ and am trying to get log4cxx to run under a little
console test application written with Visual Studio 2005 C++ 
Can you please tell me what to add where in order to make your examples
under http://logging.apache.org/log4cxx/manual.html 
work? 
With Regards, 
Johannes Frank