Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Log4cplus logging facility configuration, installation, testing     - ElasticSearch basic usage and cluster structures (Server)

- 10046 trace only open for a particular SQL statement (Database)

- Linux add a new hard disk (Linux)

- PHP generates a random password several ways (Programming)

- exp / imp Export Import version of the problem and the ORA-6550 error (Database)

- Install Visual Studio Code in Ubuntu (Linux)

- How to use the beta / unstable version of the software in Debian library (Linux)

- Proper use Core Data multithreaded 3 ways (Programming)

- Bash difference in single quotes and double quotes (Programming)

- Linux System Getting Started Learning: Using yum to download the RPM package without installing (Linux)

- How dependent on Fedora, CentOS, RHEL check RPM packages (Linux)

- Python 3 for instructions encoded string conversion (Programming)

- Mounting kit under Fedora Linux (Linux)

- C # mobile side and PC-side data exchange (Database)

- Depth understanding of C language (Programming)

- Open log in Hibernate (Programming)

- PHP Performance Analysis and Experiment: Performance Micro Analysis (Programming)

- HttpClient Tutorial (Programming)

- VMware6 achieve nat Internet (Linux)

- PF_RING 6.0.2 compiled and installed on Redhat 6.3 x86_64 (Linux)

 
         
  Log4cplus logging facility configuration, installation, testing
     
  Add Date : 2018-11-21      
         
         
         
  Log4cplus is written in C ++ open source logging system, which is very comprehensive, the initial use log4plus, described below under Linux log4cplus their own learning process configuration, installation and testing process.

1, log4cplus Introduction

log4cplus is written in C ++ open source logging system, was formerly written in java log4j system. License protected by the Apache Software. The author is Tad E. Smith. log4cplus thread-safe, flexible, and more granular control features, by prioritizing information so that it can be oriented programming commissioning, operation, testing, and maintenance life cycle; you can choose to output information to the screen, file, NT event log, and even a remote server; regular backups of the log by the specified policy.

2, log4cplus download

The latest log4cplus can be downloaded from the following URL.

log4cplus: http: //sourceforge.net/projects/log4cplus/

In RedHat Linux systems can use the following command to install:

wget http://sourceforeg.net/projects/log4cplus/files/log4cplus-stable/1.1.2/log4cplus-x.x.x.tar.gz

3, log4cplus installation

tar xvzf log4cplus-x.x.x.tar.gz

cd log4cplus-x.x.x

./configure

make

make install

4, log4cplus configuration

log4cplus default installation behind file path is / usr / local / include / log4cplus, installation files Road King library file is / usr / local / lib, edit the .bash_profile file to add the library file.

$ Vi ~ / .bash_profile

Add to:

LD_LIBRARY_PATH = LD_LIBRARY_PATH: / usr / local / lib

export LD_LIBRARY_PATH

After adding source ~ / .bash_profile changes to take effect

$ Vi / etc / profile

Add to:

CPLUS_INCLUDE_PATH = LD_LIBRARY_PATH: / usr / local / lib

export CPLUS_INCLUDE_PATH

After adding source ~ / .bash_profile changes to take effect

5, the test

#include < log4cplus / logger.h>
#include < log4cplus / configurator.h>
#include < iomanip>
#include < log4cplus / logger.h>
#include < log4cplus / fileappender.h>
#include < log4cplus / consoleappender.h>

#include < log4cplus / loggingmacros.h>
#include < log4cplus / layout.h>
#include < time.h>
using namespace std;
using namespace log4cplus;
Logger pTestLogger;

void writelog (char * leval, char * info)
{
struct tm * p;
time_t lt = time (NULL);
p = localtime (<);
char * timetemp = ctime (<);
* (Timetemp + strlen (timetemp) -1) = '\ 0';
char temp [10000];
sprintf (temp, "[% s]% s", timetemp, info);
        printf ( "temp ==% s", temp);
printf ( "leval ====% s \ n", leval);
if (memcmp (leval, "TRACE", 5) == 0)
printf ( "% d ===% d", memcmp ( "TRACE", "TRAC1E", 5), memcmp (leval, "TRACE", 5));
LOG4CPLUS_TRACE (pTestLogger, temp);
if (memcmp (leval, "DEBUG", 5) == 0)
LOG4CPLUS_DEBUG (pTestLogger, temp);
if (memcmp (leval, "INFO", 4) == 0)
LOG4CPLUS_INFO (pTestLogger, temp);
if (memcmp (leval, "WARN", 4) == 0)
LOG4CPLUS_WARN (pTestLogger, temp);
if (memcmp (leval, "ERROR", 5) == 0)
LOG4CPLUS_ERROR (pTestLogger, temp);
if (memcmp (leval, "FATAL", 5) == 0)
LOG4CPLUS_FATAL (pTestLogger, temp);
}
int main ()
{
char * info = "you have a iuns";
char filename [50];
struct tm * p;
time_t lt = time (NULL);
p = localtime (<);
sprintf (filename, "% d-% d-% d.txt", (1900 + p-> tm_year), (1 + p-> tm_mon), p-> tm_mday);
FILE * stream = fopen (filename, "wb");
SharedAppenderPtr pFileAppender (new FileAppender ((filename)));
pTestLogger = Logger :: getInstance (( "LoggerName"));
pTestLogger.addAppender (pFileAppender);
writelog ( "TRACE", info);
writelog ( "DEBUG", info);
writelog ( "ERROR", info);
        return 0;
}

Compile command

g ++ filetime.cpp -I / usr / local / log4cplus / include / -L / usr / local / log4cplus / lib -llog4cplus -o filetime
     
         
         
         
  More:      
 
- Import and export myloader accelerate mydumper (Database)
- Linux suffered SYN flood attack setting (Linux)
- Elementary OS Freya global menu (Linux)
- Linux yum command Detailed (Linux)
- Linux ./configure --prefix command (Linux)
- JDK installation and configuration environment variable under linuxb (Linux)
- 64-bit Ubuntu 15.10 How to compile the latest version of the 32 Wine 1.7.53 (Linux)
- Oracle 11g maintenance partitions (eight) - Renaming Partitions (Database)
- Linux System Getting Started Tutorial: How to Force Change your password at next logon Linux (Linux)
- MySQL5.7 JSON type using presentation (Database)
- Not safe procedure under Linux (Linux)
- wget command usage Explanation (Linux)
- Xshell configure SSH free password (Server)
- MySQL High Availability plan several options (Database)
- ApacheDS configuration of users and user groups to achieve SSO (Server)
- Installation and deployment of MariaDB under CentOS (Database)
- libreadline.so.6: can not open shared object file problem solution (Linux)
- LMMS 1.03 install on Ubuntu 14.04 (Linux)
- How nodeclub constructed Docker image (Server)
- Parameters of the extra port MySQL 5.6 (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.