ubuntu log4cxx安装和使用

本文提供了Log4cxx在Ubuntu下的详细安装步骤,包括所需辅助库apr和apr-util的配置及安装,以及针对特定文件的修改建议,确保Log4cxx能够成功部署。
  • 安装说明

log4cxx的官方下载地址是http://logging.apache.org/log4cxx/index.html ,log4cxx的使用需要两个辅助库,
apr和apr-util的官方下载地址是http://apr.apache.org/download.cgi,apr我用的是apr-1.6.2.tar.gz,apr-util我用的是apr-util-1.6.0.tar.gz

  • apr安装
$ ./configure --prefix=/usr/local/apr
$ make
$ make install
  • apr-util安装
$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$ make
$ make install
  • log4cxx安装
在Ubuntu下安装还需要做以下修改:
apache-log4cxx-0.10.0/src/main/cpp/inputstreamreader.cpp ------> 追加头文件string.h
apache-log4cxx-0.10.0/src/main/cpp/socketoutputstream.cpp ------> 追加头文件string.h
apache-log4cxx-0.10.0/src/examples/cpp/console.cpp ------> 追加头文件string.h和stdio.h

$ ./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
$ make
$ make install
  • 添加搜索路径
 使用locate查找安装路径
$ locate liblog4cxx.so
$ vi /etc/ld.so.conf 添加路径,我库安装在/usr/local/log4cxx/lib
$ ldconfig
这样就可以了。
补充说明 fa@zcn:~/mycode/simulation$ rufa@zcn:~/mycode/simulation$ dpkg -L liblog4cxx-dev # 确认包含log4cxx-config.cmake文件 /. /usr /usr/include /usr/include/log4cxx /usr/include/log4cxx/appender.h /usr/include/log4cxx/appenderskeleton.h /usr/include/log4cxx/asyncappender.h /usr/include/log4cxx/basicconfigurator.h /usr/include/log4cxx/config /usr/include/log4cxx/config/propertysetter.h /usr/include/log4cxx/consoleappender.h /usr/include/log4cxx/dailyrollingfileappender.h /usr/include/log4cxx/db /usr/include/log4cxx/db/odbcappender.h /usr/include/log4cxx/defaultconfigurator.h /usr/include/log4cxx/defaultloggerfactory.h /usr/include/log4cxx/file.h /usr/include/log4cxx/fileappender.h /usr/include/log4cxx/filter /usr/include/log4cxx/filter/andfilter.h /usr/include/log4cxx/filter/denyallfilter.h /usr/include/log4cxx/filter/expressionfilter.h /usr/include/log4cxx/filter/levelmatchfilter.h /usr/include/log4cxx/filter/levelrangefilter.h /usr/include/log4cxx/filter/locationinfofilter.h /usr/include/log4cxx/filter/mapfilter.h /usr/include/log4cxx/filter/propertyfilter.h /usr/include/log4cxx/filter/stringmatchfilter.h /usr/include/log4cxx/helpers /usr/include/log4cxx/helpers/absolutetimedateformat.h /usr/include/log4cxx/helpers/appenderattachableimpl.h /usr/include/log4cxx/helpers/aprinitializer.h /usr/include/log4cxx/helpers/bufferedoutputstream.h /usr/include/log4cxx/helpers/bufferedwriter.h /usr/include/log4cxx/helpers/bytearrayinputstream.h /usr/include/log4cxx/helpers/bytearrayoutputstream.h /usr/include/log4cxx/helpers/bytebuffer.h /usr/include/log4cxx/helpers/cacheddateformat.h /usr/include/log4cxx/helpers/charsetdecoder.h /usr/include/log4cxx/helpers/charsetencoder.h /usr/include/log4cxx/helpers/class.h /usr/include/log4cxx/helpers/classregistration.h /usr/include/log4cxx/helpers/condition.h /usr/include/log4cxx/helpers/cyclicbuffer.h /usr/include/log4cxx/helpers/datagrampacket.h /usr/include/log4cxx/helpers/datagramsocket.h /usr/include/log4cxx/helpers/date.h /usr/include/log4cxx/helpers/dateformat.h /usr/include/log4cxx/helpers/datelayout.h /usr/include/log4cxx/helpers/datetimedateformat.h /usr/include/log4cxx/helpers/exception.h /usr/include/log4cxx/helpers/fileinputstream.h /usr/include/log4cxx/helpers/fileoutputstream.h /usr/include/log4cxx/helpers/filewatchdog.h /usr/include/log4cxx/helpers/inetaddress.h /usr/include/log4cxx/helpers/inputstream.h /usr/include/log4cxx/helpers/inputstreamreader.h /usr/include/log4cxx/helpers/integer.h /usr/include/log4cxx/helpers/iso8601dateformat.h /usr/include/log4cxx/helpers/loader.h /usr/include/log4cxx/helpers/locale.h /usr/include/log4cxx/helpers/loglog.h /usr/include/log4cxx/helpers/messagebuffer.h /usr/include/log4cxx/helpers/mutex.h /usr/include/log4cxx/helpers/object.h /usr/include/log4cxx/helpers/objectimpl.h /usr/include/log4cxx/helpers/objectoutputstream.h /usr/include/log4cxx/helpers/objectptr.h /usr/include/log4cxx/helpers/onlyonceerrorhandler.h /usr/include/log4cxx/helpers/optionconverter.h /usr/include/log4cxx/helpers/outputstream.h /usr/include/log4cxx/helpers/outputstreamwriter.h /usr/include/log4cxx/helpers/pool.h /usr/include/log4cxx/helpers/properties.h /usr/include/log4cxx/helpers/propertyresourcebundle.h /usr/include/log4cxx/helpers/reader.h /usr/include/log4cxx/helpers/relativetimedateformat.h /usr/include/log4cxx/helpers/resourcebundle.h /usr/include/log4cxx/helpers/serversocket.h /usr/include/log4cxx/helpers/simpledateformat.h /usr/include/log4cxx/helpers/socket.h /usr/include/log4cxx/helpers/socketoutputstream.h /usr/include/log4cxx/helpers/strftimedateformat.h /usr/include/log4cxx/helpers/strictmath.h /usr/include/log4cxx/helpers/stringhelper.h /usr/include/log4cxx/helpers/stringtokenizer.h /usr/include/log4cxx/helpers/synchronized.h /usr/include/log4cxx/helpers/syslogwriter.h /usr/include/log4cxx/helpers/system.h /usr/include/log4cxx/helpers/systemerrwriter.h /usr/include/log4cxx/helpers/systemoutwriter.h /usr/include/log4cxx/helpers/tchar.h /usr/include/log4cxx/helpers/thread.h /usr/include/log4cxx/helpers/threadlocal.h /usr/include/log4cxx/helpers/threadspecificdata.h /usr/include/log4cxx/helpers/timezone.h /usr/include/log4cxx/helpers/transcoder.h /usr/include/log4cxx/helpers/transform.h /usr/include/log4cxx/helpers/writer.h /usr/include/log4cxx/helpers/xml.h /usr/include/log4cxx/hierarchy.h /usr/include/log4cxx/htmllayout.h /usr/include/log4cxx/layout.h /usr/include/log4cxx/level.h /usr/include/log4cxx/log4cxx.h /usr/include/log4cxx/logger.h /usr/include/log4cxx/logmanager.h /usr/include/log4cxx/logstring.h /usr/include/log4cxx/mdc.h /usr/include/log4cxx/ndc.h /usr/include/log4cxx/net /usr/include/log4cxx/net/smtpappender.h /usr/include/log4cxx/net/socketappender.h /usr/include/log4cxx/net/socketappenderskeleton.h /usr/include/log4cxx/net/sockethubappender.h /usr/include/log4cxx/net/syslogappender.h /usr/include/log4cxx/net/telnetappender.h /usr/include/log4cxx/net/xmlsocketappender.h /usr/include/log4cxx/nt /usr/include/log4cxx/nt/nteventlogappender.h /usr/include/log4cxx/nt/outputdebugstringappender.h /usr/include/log4cxx/pattern /usr/include/log4cxx/pattern/classnamepatternconverter.h /usr/include/log4cxx/pattern/datepatternconverter.h /usr/include/log4cxx/pattern/filedatepatternconverter.h /usr/include/log4cxx/pattern/filelocationpatternconverter.h /usr/include/log4cxx/pattern/formattinginfo.h /usr/include/log4cxx/pattern/fulllocationpatternconverter.h /usr/include/log4cxx/pattern/integerpatternconverter.h /usr/include/log4cxx/pattern/levelpatternconverter.h /usr/include/log4cxx/pattern/linelocationpatternconverter.h /usr/include/log4cxx/pattern/lineseparatorpatternconverter.h /usr/include/log4cxx/pattern/literalpatternconverter.h /usr/include/log4cxx/pattern/loggerpatternconverter.h /usr/include/log4cxx/pattern/loggingeventpatternconverter.h /usr/include/log4cxx/pattern/messagepatternconverter.h /usr/include/log4cxx/pattern/methodlocationpatternconverter.h /usr/include/log4cxx/pattern/nameabbreviator.h /usr/include/log4cxx/pattern/namepatternconverter.h /usr/include/log4cxx/pattern/ndcpatternconverter.h /usr/include/log4cxx/pattern/patternconverter.h /usr/include/log4cxx/pattern/patternparser.h /usr/include/log4cxx/pattern/propertiespatternconverter.h /usr/include/log4cxx/pattern/relativetimepatternconverter.h /usr/include/log4cxx/pattern/threadpatternconverter.h /usr/include/log4cxx/pattern/throwableinformationpatternconverter.h /usr/include/log4cxx/patternlayout.h /usr/include/log4cxx/portability.h /usr/include/log4cxx/private /usr/include/log4cxx/private/log4cxx_private.h /usr/include/log4cxx/propertyconfigurator.h /usr/include/log4cxx/provisionnode.h /usr/include/log4cxx/rolling /usr/include/log4cxx/rolling/action.h /usr/include/log4cxx/rolling/filerenameaction.h /usr/include/log4cxx/rolling/filterbasedtriggeringpolicy.h /usr/include/log4cxx/rolling/fixedwindowrollingpolicy.h /usr/include/log4cxx/rolling/gzcompressaction.h /usr/include/log4cxx/rolling/manualtriggeringpolicy.h /usr/include/log4cxx/rolling/rollingfileappender.h /usr/include/log4cxx/rolling/rollingfileappenderskeleton.h /usr/include/log4cxx/rolling/rollingpolicy.h /usr/include/log4cxx/rolling/rollingpolicybase.h /usr/include/log4cxx/rolling/rolloverdescription.h /usr/include/log4cxx/rolling/sizebasedtriggeringpolicy.h /usr/include/log4cxx/rolling/timebasedrollingpolicy.h /usr/include/log4cxx/rolling/triggeringpolicy.h /usr/include/log4cxx/rolling/zipcompressaction.h /usr/include/log4cxx/rollingfileappender.h /usr/include/log4cxx/simplelayout.h /usr/include/log4cxx/spi /usr/include/log4cxx/spi/appenderattachable.h /usr/include/log4cxx/spi/configurator.h /usr/include/log4cxx/spi/defaultrepositoryselector.h /usr/include/log4cxx/spi/errorhandler.h /usr/include/log4cxx/spi/filter.h /usr/include/log4cxx/spi/hierarchyeventlistener.h /usr/include/log4cxx/spi/location /usr/include/log4cxx/spi/location/locationinfo.h /usr/include/log4cxx/spi/loggerfactory.h /usr/include/log4cxx/spi/loggerrepository.h /usr/include/log4cxx/spi/loggingevent.h /usr/include/log4cxx/spi/optionhandler.h /usr/include/log4cxx/spi/repositoryselector.h /usr/include/log4cxx/spi/rootlogger.h /usr/include/log4cxx/spi/triggeringeventevaluator.h /usr/include/log4cxx/stream.h /usr/include/log4cxx/ttcclayout.h /usr/include/log4cxx/varia /usr/include/log4cxx/varia/fallbackerrorhandler.h /usr/include/log4cxx/writerappender.h /usr/include/log4cxx/xml /usr/include/log4cxx/xml/domconfigurator.h /usr/include/log4cxx/xml/xmllayout.h /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/liblog4cxx.a /usr/lib/x86_64-linux-gnu/pkgconfig /usr/lib/x86_64-linux-gnu/pkgconfig/liblog4cxx.pc /usr/share /usr/share/doc /usr/share/doc/liblog4cxx-dev /usr/share/doc/liblog4cxx-dev/copyright /usr/share/doc/liblog4cxx-dev/examples /usr/share/doc/liblog4cxx-dev/examples/Makefile.am /usr/share/doc/liblog4cxx-dev/examples/console.cpp /usr/share/doc/liblog4cxx-dev/examples/delayedloop.cpp /usr/share/doc/liblog4cxx-dev/examples/stream.cpp /usr/share/doc/liblog4cxx-dev/examples/trivial.cpp /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/liblog4cxx-dev /usr/lib/x86_64-linux-gnu/liblog4cxx.so /usr/share/doc/liblog4cxx-dev/NOTICE /usr/share/doc/liblog4cxx-dev/changelog.Debian.gz rufa@zcn:~/mycode/simulation$
最新发布
05-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值