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