Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

cxxjava/CxxLog4j

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CxxLog4j

C++ logging library like Log4j

chinese version: 简体中文

Table of Contents

Characteristics

  • Cross platform: support Linux32/64, OSX64, Win64 platforms;
  • High performance: with the advantages of C/C++ and Java concurrent Libraries tegother, bursting performance;
  • Easy development: High imitation from Log4j1.2, support multiple log format output, api easy to use;
  • New feature: support modify log configuration file when program is running!

Example

c++:

#include "Efc.hh"
#include "ELog.hh"

static sp<ELogger> logger = ELoggerManager::getLogger("XXX.YYY.ZZZ");

static void test_logger() {
  try {
    throw EException(__FILE__, __LINE__, "error");
  } catch (EException& e) {
    logger->error(e);
  }
  
  logger->trace("no log file line number information");
  logger->trace(__FILE__, __LINE__, "message");
}

int main(int argc, const char **argv) {
  // CxxJDK init.
  ESystem::init(argc, argv);
  // CxxLog4j init.
  ELoggerManager::init("log4e.properties");
  
  while (true) {
    test_logger();
    
    ELoggerManager::flushConfig(); //refresh configuration!
    EThread::sleep(500);
  }
  
  return 0;
}

testlog

more examples:
testlog.cpp

Configuration

Reference the log4j 1.2 official properties configuration manual.

Example: log4e.properties

New feature: CxxLog4j support the definition of internal variables, the method for obtaining the variable value is like $(variable), see:

log.path = ./

log4j.appender.file.File = ${log.path}/logs/all.log

Dependency

CxxLog4j is based on CxxJDK.

TODO

AsyncAppender

Support

Email: cxxjava@163.com

About

C++ logging library like Log4j

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.