Log4cxx compilation and usage records in Windows

Source: Internet
Author: User

There have been many similar articles on csdn. Here, we will simply mark it.

Windows 2003 + vs 2003.net

You must first download multiple projects: Apr, aprutil, APR-iconv, log4cxx, and log4cxx.

Apr, aprutil, and APR-iconv:
Log4cxx: Logging

Decompress and rename the file as follows:
Apache-log4cxx-0.10.0 ---> log4cxx
Apr-1.4.6 ---> APR
Apr-util-1.4.1 --> Apr-util
Apr-iconv-1.2.1 ---> Apr-iconv

Then open F: \ log4cxx_use \ log4cxx \ projects \ log4cxx. sln. solution is as follows:
You can manually add a project that does not exist.

Add the include directory in the Options dialog box:

Then, compile Apr, aprutil, and apriconv.
Next, configure the project dependency attribute of log4cxx, for example:

Then you can start compiling log4cxx.

Log4cxx usage instructions are as follows:
Add project dependency Lib:

The sample code is as follows:

# Include <iostream> # include <log4cxx/logger. h> # include <log4cxx/basicconfigurator. h> # include <log4cxx/propertyconfigurator. h> # include <log4cxx/XML/domconfigurator. h> # include <log4cxx/helpers/exception. h> using namespace log4cxx; using namespace log4cxx: XML; using namespace log4cxx: Helpers; int main () {basicconfigurator: Configure (); propertyconfigurator: Configure ("log4j. properties "); loggerptr rootlogger = logger: getrootlogger (); rootlogger-> debug (" it does work "); Return 0 ;}

Log4j. properties is configured as follows:

log4j.rootLogger=debug, Rlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%nlog4j.appender.R=org.apache.log4j.RollingFileAppenderlog4j.appender.R.File=hello.loglog4j.appender.R.MaxFileSize=100KBlog4j.appender.R.MaxBackupIndex=10log4j.appender.R.layout=org.apache.log4j.PatternLayoutlog4j.appender.R.layout.ConversionPattern=%5p %c [%t] - %m%n

The final output file hello. log:
Debug root [0x00001720]-It does work

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.