Open-source log system-log4cplus (1)

Source: Internet
Author: User

 

 

### Introduction ###

Log4cplus is an open-source log system written in C ++. Its predecessor was the log4j system written in Java.
Protection. The author is Tad E. Smith. Log4cplus features thread security, flexibility, and multi-granularity control.
Priority allows you to perform full-lifecycle debugging, running, testing, and maintenance for programs. You can choose to output information to screens, files,
NT Event Log, or even remote server; Regularly backs up logs by specifying a policy.
### Download ###
The latest log4cplus can download http://log4cplus.sourceforge.net from the following URL
### Installation ###
1. Installation in Linux
tar xvzf log4cplus-x.x.x.tar.gz
cd log4cplus-x.x.x
./configure --prefix=/where/to/install
make
make install
Here I use the default installation path:/usr/local. Unless otherwise specified, this path prevails.
2. Installation in Windows
No installation is required. msvc8 stores various DSP and SLB files. You can use Visual Studio 2005 to open the file. Compile the file before use.
"Log4cplus_dll class" project to generate DLL, or compile the "log4cplus_static class" project to generate Lib. If you have any compilation problems, contact
Me: bicheng.gui@gmail.com.

### Previous configuration ###
1. Linux Configuration
Make sure that your makefile contains/usr/local/lib/liblog4cplus. A (static library) or-llog4cplus (dynamic library,
The header file is in the/usr/local/include/log4cplus directory. To use dynamic libraries properly, you must add the library installation path
In LD_LIBRARY_PATH, I usually log on as an administrator and add the installation path to/etc/lD. So. conf. Here
Yes/usr/local/lib, and then execute ldconfig to make the settings take effect.
2. configuration in Windows
Insert the DSP file of the "log4cplus_dll class" project or "log4cplus_static class" project to your project, or directly
Put the libraries and directories of header files generated by the compilation of two projects in the search path of your project. If you use static libraries, please go to your project
Add log4cplus_static to Preprocessor definitions of "Project/setting/C ++.
Elements
Although the function is powerful, it should be said that log4cplus is complicated to use. To better use it, first introduce its basic elements.
Layouts: layouts to control the format and layout of output logs.
Appenders: controls the output of log record operations, works closely with the layout, and outputs messages in specific formats to the output terminal.
Supports screen, file, socket, etc.
Logger: the logger object that stores and manages object log information changes. When you need to perform
You need to generate a logger.
Categories: classifier, hierarchy structure, used to classify recorded information.
Each node maintains all the information of a logger.
Priorities: log priority, including trace, debug, info, warning, error, and fatal.

This article describes the basic concepts of log4cplus and how to install and configure log4cplus. The next article describes how to use log4cplus through examples.

 

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.