Log4cplus Configuration File Example

Source: Internet
Author: User

Recently in pondering Log4cplus, this is indeed an artifact.

It's easy to use, but the script takes some time to understand.

OK, no more nonsense, the following is my configuration of the script, I hope to give friends some help:

[Plain]  View Plain  copy log4cplus.rootlogger=trace, stdout, all_msgs, err_msgs, debug_ msgs, specifial_msgs         log4cplus.appender.stdout=log4cplus:: consoleappender   log4cplus.appender.stdout.encoding=utf-8         log4cplus.appender.all_msgs=log4cplus::rollingfileappender   Log4cplus.appender.ALL_MSGS. file=./log/run.log   Log4cplus.appender.ALL_MSGS. appender=log4cplus::rollingfileappender   Log4cplus.appender.ALL_MSGS. queuelimit=100000   Log4cplus.appender.ALL_MSGS. maxfilesize=1024mb   Log4cplus.appender.ALL_MSGS. maxbackupindex=100   Log4cplus.appender.ALL_MSGS. encoding=utf-8   Log4cplus.appender.all_msgs.layout=log4cplus::P atternlayout   log4cplus.appender.all_msgs.layout.conversionpattern=%d{%y%m/%d %h:%m:%s} %-5p %c{2} %%%x% % - %m [%l]%n   #log4cplus. AppendEr. All_msgs. appender.immediateflush=false   #log4cplus. Appender.all_msgs. appender.buffersize=1024         log4cplus.appender.err_msgs=log4cplus:: rollingfileappender   Log4cplus.appender.ERR_MSGS. file=./log/error.log   Log4cplus.appender.ERR_MSGS. appender=log4cplus::rollingfileappender   Log4cplus.appender.ERR_MSGS. queuelimit=100000   Log4cplus.appender.ERR_MSGS. maxfilesize=1024mb   Log4cplus.appender.ERR_MSGS. maxbackupindex=100   Log4cplus.appender.ERR_MSGS. encoding=utf-8   Log4cplus.appender.err_msgs.layout=log4cplus::P atternlayout   log4cplus.appender.err_msgs.layout.conversionpattern=%d{%y%m/%d %h:%m:%s} %-5p %c{2} %%%x% % - %m [%l]%n   LOG4CPLUS.APPENDER.ERR_MSGS.FILTERS.1=LOG4CPLUS::SPI:: loglevelmatchfilter   log4cplus.appender.err_msgs.filters.1.logleveltomatch=error   log4cplus.appender.ERR_MSGS.filters.1.acceptonmatch=true   Log4cplus.appender.err_msgs.filters.2=log4cplus::spi::D enyallfilter          log4cplus.appender.debug_msgs=log4cplus::rollingfileappender   Log4cplus.appender.DEBUG_MSGS. file=./log/debug.log   Log4cplus.appender.DEBUG_MSGS. appender=log4cplus::rollingfileappender   Log4cplus.appender.DEBUG_MSGS. queuelimit=100000   Log4cplus.appender.DEBUG_MSGS. maxfilesize=1024mb   Log4cplus.appender.DEBUG_MSGS. maxbackupindex=100   Log4cplus.appender.DEBUG_MSGS. encoding=utf-8   Log4cplus.appender.debug_msgs.layout=log4cplus::P atternlayout   log4cplus.appender.debug_msgs.layout.conversionpattern=%d{%y%m/%d %h:%m:%s} %-5p %c{2} %%% x%% - %m [%l]%n   LOG4CPLUS.APPENDER.DEBUG_MSGS.FILTERS.1=LOG4CPLUS::SPI:: loglevelmatchfilter   log4cplus.appender.debug_msgs.filters.1.logleveltomatch=debug   Log4cplus. Appender. debug_msgs.filters.1.acceptonmatch=true   Log4cplus.appender.debug_msgs.filters.2=log4cplus::spi::D enyallfilter         log4cplus.appender.specifial_msgs=log4cplus:: rollingfileappender   Log4cplus.appender.SPECIFIAL_MSGS. file=./log/specifial.log   Log4cplus.appender.SPECIFIAL_MSGS. appender=log4cplus::rollingfileappender   Log4cplus.appender.SPECIFIAL_MSGS. queuelimit=100000   Log4cplus.appender.SPECIFIAL_MSGS. maxfilesize=1024mb   Log4cplus.appender.SPECIFIAL_MSGS. maxbackupindex=100   Log4cplus.appender.SPECIFIAL_MSGS. encoding=utf-8   Log4cplus.appender.specifial_msgs.layout=log4cplus::P atternlayout   LOG4CPLUS.APPENDER.SPECIFIAL_MSGS.LAYOUT.CONVERSIONPATTERN=%D{%Y%M/%D %H:%M:%S} %-5P %C{2}  %%%x%% - %m [%l]%n   LOG4CPLUS.APPENDER.SPECIFIAL_MSGS.FILTERS.1=LOG4CPLUS::SPI: :stringmatchfilter   Log4cplus.appendEr. specifial_msgs.filters.1.stringtomatch=specifial   log4cplus.appender.SPECIFIAL_ msgs.filters.1.acceptonmatch=true   Log4cplus.appender.specifial_msgs.filters.2=log4cplus::spi::D enyallfilter  
This script supports:

STDOUT: Screen printing,

ALL_MSGS: All messages are written to the log,

ERR_MSGS: Error message written to error log,

The Debug_msgs:debug log is written to the debug log file,

SPECIFIAL_MSGS: The message that matches the specified string is written to the specified log file.


Test code:

[CPP] view plain copy #include <iostream> #include <log4cplus/logger.h> #include <log4cplus/ Configurator.h>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.