Skip to content

Instantly share code, notes, and snippets.

@kumagi
Created January 18, 2016 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumagi/57b56980e0b2e45187bd to your computer and use it in GitHub Desktop.
Save kumagi/57b56980e0b2e45187bd to your computer and use it in GitHub Desktop.
#include <string>
#include <iostream>
#include <log4cxx/logger.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/properties.h>
#include <assert.h>
log4cxx::LoggerPtr logger_ __attribute__((init_priority(10)));
int main() {
///* static */ log4cxx::LoggerPtr logger_;
log4cxx::helpers::Properties p;
p.put("log4j.rootLogger", "INFO, stderr");
p.put("log4j.appender.stderr", "org.apache.log4j.ConsoleAppender");
p.put("log4j.appender.stderr.Target", "System.err");
p.put("log4j.appender.stderr.DatePattern", "'.'yyyy-MM-dd");
p.put("log4j.appender.stderr.layout", "org.apache.log4j.PatternLayout");
p.put("log4j.appender.stderr.layout.ConversionPattern",
"%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t] - %m%n");
log4cxx::PropertyConfigurator::configure(p);
std::setlocale(LC_CTYPE, "ja_JP.UTF-8");
logger_ = log4cxx::Logger::getLogger("hogefuga");
assert(logger_ != 0);
LOG4CXX_INFO(logger_, "hello");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment