So I heard good things about boost log. This claims its existence:
http://boost-log.sourceforge.net/libs/log/doc/html/index.html
This is the tutorial:
http://boost-log.sourceforge.net/libs/log/doc/html/log/tutorial.html#log.tutorial.trivial
However, boost log is not part of boost. Hence not in the regular boost branch.
One can download boost log separately from here:
http://sourceforge.net/projects/boost-log/
I might just be too inexperienced, but I find the installation instructions very poor. Nonetheless, after downloading and copying the folders boost and lib into the boost folder, I can run bootstrap and bjam. This fails with errors relating to Boost.Filesystem versions, similar to the ones mentioned here:
http://boost.2283326.n4.nabble.com/Boost-Log-compilation-on-msvc-2010-fail-td3488502.html
The recommendation from Andrew Semashev (in above link) is to "Please use Boost.Log v2 (from SVN trunk)."
Looking at https://boost-log.svn.sourceforge.net/svnroot/boost-log, I can only see version 1.
Looking at http://svn.boost.org/svn/boost/sandbox/, I can find boost logging v2 by John Torjo. However, just from the syntax that might not be the boost log v2 that Andrew Semashev is talking about.
Seeing that I spend way too many hours on this already, I figured I'd get some help, and maybe some other people might profit from this post and the answers and save themselves some time. I don't think it has been answered before, and answers like these change I supposed.
So, here goes: What is boost log v2 that Andrew Semashev is talking about? Is it the same as John Torjo's? If not, where I can find it? And how do I build it?
Thanks
P.S. I should mention this is on Windows with Visual Studio Express 2010
P.P.S. Guess "version 2", which is apparently just the SVN, also has problems, but with this line (see Sergio's answer below)
<toolset>msvc:<define>BOOST_FILESYSTEM_VERSION=2
in the bjam file at least I can compile. However, this file
#include <boost/log/trivial.hpp> int main(int, char*[]) { BOOST_LOG_TRIVIAL(trace) << "A trace severity message"; BOOST_LOG_TRIVIAL(debug) << "A debug severity message"; BOOST_LOG_TRIVIAL(info) << "An informational severity message"; BOOST_LOG_TRIVIAL(warning) << "A warning severity message"; BOOST_LOG_TRIVIAL(error) << "An error severity message"; BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message"; }
straight out of the tutorial, albeit now compiling and linking, doesn't produce any output...
Log. Boost. Log is the logging library in Boost.
Boost. Build is a high-level build system which makes it as easy as possible to manage C++ projects. The idea is to specify in configuration files just as much as necessary to build a program. For example it is not required to tell Boost. Build how to use a certain compiler.
This is the method I followed to install Boost.Log in my Linux box. One important note before you build and install Boost libraries: Make sure you have installed a threading library like pthreads
. Most package managers should have them.
Here are the build steps:
If you have installed Boost already from source, then its fine continue to next step. Otherwise download it from here (preferably the latest version (v1.46). I used v1.45). Extract the boost libraries at say: /opt
. We can build the libraries along with Boost.Log.
/opt
. Copy the log folder in: /opt/boost-log-1.0/boost
to your boost source directory /opt/Boost_1_45_0/boost
(assuming that you have extracted it in /opt
)./opt/boost-log-1.0/libs
to your boost libs directory /opt/Boost_1_45_0/libs
(assuming that you have extracted it in /opt
). If you haven’t installed other Boost libraries, then follow these steps: cd /opt/Boost_1_45_0
.bootstrap.sh --show-libraries
— this will list all the libraries that will be built and installed. You should see log
listed as part of it..bootstrap.sh --with-libraries=all --prefix=/usr/local --includedir=/usr/local/include --libdir=/usr/local/lib
./bjam install
Finally make sure $LD_LIBRARY_PATH
has /usr/local/lib
(the path specified in bjam
to install the built libraries) as part of it. If it is not edit your ~/.bashrc
and add the following:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH
boost log v2 is simply what you get by checking out trunk, according to what Andrey says in the post you link.
indeed, it seems that this version too has got problems compiling against boost::filesystem v3.
if this is also your case, one workaround is compiling after adding
<define>BOOST_FILESYSTEM_VERSION=2
to the jamfile.
if this does not work, then, check whether you are building a single threaded or multi-threaded version of the libraries. multi-threadred boost-log should be more tested (according to Andrey).
hope this helps... I have not tried it...
EDIT:
where to add the ?
I would add it to the requirements
section of boost-log/libs/log/build/Jamfile.v2
, shared
subsection:
project boost/log : source-location ../src : requirements <link>shared:<define>BOOST_LOG_DLL <link>shared:<define>BOOST_FILESYSTEM_VERSION=2
EDIT: from Cookie's comment, BOOST_FILESYSTEM_VERSION=2
should be specified as
<link>msvc:<define>BOOST_FILESYSTEM_VERSION=2
not in shared
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With