Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Log4cplus logging facility configuration, installation, testing     - CUDA (including GPU card driver) installation process under Ubuntu (Linux)

- CentOS7 installation performance monitoring system (Server)

- Ora-00020: maximum number of processes (500) exceeded (Database)

- Docker: Mirroring and container operations (Server)

- Linux server startup and logon security settings (Linux)

- Installation Atom text editor on Mint Ubuntu / Linux (Linux)

- Linux System Administrator common interview questions and answers 30 (Linux)

- Why I do not like the Go language style interface (ie Structural Typing) (Programming)

- Ubuntu 10.10 install Oracle 10g Installation Guide (Database)

- Nginx introduced Dynamic Module Architecture (Server)

- On the Web application attack techniques Common (Linux)

- Linux + Apache + PHP + Oracle based environment to build (Server)

- HBase cluster installation and deployment (Server)

- top command causes the system load increases (Linux)

- How to manage start-up applications in Ubuntu (Linux)

- Use Vagrant build cross-platform development environment for Python (Server)

- Run Windows in FreeBSD bhyve (Linux)

- Configuring s3c-linux-2.6.28.6-Real6410 appears Unable to find the QT3 installation (Linux)

- CentOS 6.6 install JDK7 (Linux)

- Mac OS X system setup Google Go language development environment configuration tool Sublime Text 2 (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:      
 
- Oracle 11g statistics collection - collection of multi-column statistics (Database)
- Android Scroller call mechanism and the relationship of computeScroll (Programming)
- Java Annotation Comments (Programming)
- ORA-00600: internal error code, arguments: [keltnfy-ldmInit], [46], [1], [], [], [], [], [] (Database)
- CentOS7 installation GAMIT and GMT (Linux)
- Linux Desktop allows exceptionally different launch applications (Linux)
- Single-node Hadoop environment to build (Server)
- Java in the inverter and covariance (Programming)
- Linux system monitoring, top command of the diagnostic tool Detailed (Linux)
- Monitoring network traffic with Iptraf in Linux environment (Linux)
- Oracle to create an external table (Database)
- Android webView URL redirects affect goBack () (Programming)
- After installation of Debian 6.0 do a few things first (Linux)
- Security experience: to see how the experts deal with DDoS attacks (Linux)
- Comparison of C # and Java (Programming)
- Ubuntu and derived versions of the user how to install G Mic 1.5.8.5 (Linux)
- RHEL5.8 physical opportunities to Read-only file system (Linux)
- Linux port scanning (Linux)
- Python 2.7 installed on CentOS 6.5 (Linux)
- Configure the Linux kernel and use iptables to do port mapping (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.