Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Log4cplus logging facility configuration, installation, testing     - How to install and use the Snort in Ubuntu 15.04 (Linux)

- How to add and delete bookmarks in Ubuntu (Linux)

- Linux package management (Linux)

- B-tree - ideas and implementation of C language code (Programming)

- How to configure Proftpd server on Fedora 22 (Server)

- Oracle index visible and hidden (visible / invisible) (Database)

- IIS virtual host of safety knowledge (Linux)

- Axel install plug under CentOS 5/6 acceleration yum downloads (Linux)

- CentOS directory structure Explanation (Linux)

- Using Vagrant to build multi-platform environment (Server)

- Oracle how to assess the true concurrent session (Database)

- Storm basic framework for analysis (Programming)

- Linux kernel compilation, the configuration of the motor drive (Programming)

- Linux systems for entry-learning: Install closed-source packages in Debian (Linux)

- Java Foundation - Getting Start (Programming)

- Get basic information about Linux server script (Server)

- Shell Scripting Basics (Linux)

- View processes and threads under Linux (Linux)

- How to enable Software Collections (SCL) on CentOS (Server)

- Java memory area and memory overflow exception (Programming)

 
         
  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:      
 
- Qt shared memory interprocess communication (Programming)
- In the case of using cgroups Ubuntu 14.04 and Docker (Linux)
- Compile Android libwebcore.so error occurs when solving (Programming)
- Install minimize RHEL / CentOS 7 some things need to do (Linux)
- Using a proxy method under Linux terminal (Linux)
- Linux operating system security can not be ignored (Linux)
- Linux User Management (Linux)
- 127.0.0.1 and localhost difference (Server)
- Linux command Detailed chpasswd bulk edit user password (Linux)
- Linux non-root user uses less than 1024 ports (Linux)
- Between the two to achieve the main MySQL database synchronization from (Database)
- Oracle row and column switch to turn columns (Database)
- MySQL In can not be overridden with an internal connection (Database)
- ASM Disk Space Check (Database)
- Installation on Ubuntu class Winamp audio player Qmmp 0.9.0 (Linux)
- Installed in the desktop version of Ubuntu Unity Tweak Tool (Linux)
- CentOS 6.5 opens the Xmanager Remote Desktop login (Linux)
- Redhat Close SELinux correct step (Linux)
- Windows 7 hard disk to install Ubuntu 14.10 (Linux)
- Ubuntu 10.10 install Oracle 10g graphic tutorials (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.