Git Product home page Git Product logo

Comments (7)

wilx avatar wilx commented on May 28, 2024

First off, you really need to be more precise as to what does not work. I my crystal ball is broken. :)

            LOG4CPLUS_TEXT
            (
                "log4cplus.rootLogger=TRACE, stdout\n"
                "log4cplus.appender.stdout=log4cplus::ConsoleAppender\n"
                "log4cplus.appender.stdout.Threshold=TRACE\n"
                "log4cplus.appender.stdout.Target=System.out\n"
                "log4cplus.appender.stdout.layout=log4cplus::PatternLayout\n"
                "log4cplus.appender.stdout.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S,%q} %p %t %c %L: %m%n\n"
            )

This will not work, IIRC. You have to wrap each individual string literal with LOG4CPLUS_TEXT().

If you are using master branch then you should use the log4cplus::Initializer approach instead of calling log4cplus::initialize() yourself. If you are using earlier branches, well, you are stuck with this call.

static intmax_t dummy = initialize();

Do not do this! Initialize at the top of your main() function instead (cf. static initialization order fiasco). Also, see my previous comment.

log4cplus::Logger LOGGER = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("int main(void)"));

There is no point naming your logger with full signature of your function. Since you are using PatternLayout you can use the %M specifier to get function name in the output. Better name the logger just "main".

from log4cplus.

wilx avatar wilx commented on May 28, 2024

Oh, and I have noticed two more issues:

::log4cplus::tistringstream const log4cplusProperties

Remove the const. It is obviously not a constant object.

* const_cast<::log4cplus::tistringstream *>(& log4cplusProperties)

Do not do this. Just remove the const on log4cplusProperties at its declaration point.

from log4cplus.

xiaoshuang-lu avatar xiaoshuang-lu commented on May 28, 2024

Hi, thanks for your comments.

  1. It would be great if example code posted in http://sourceforge.net/p/log4cplus/wiki/CodeExamples/ is updated. ::log4cplus::initialize() was coped from there.
  2. static intmax_t dummy = initialize(); has no problems. I have already kept the initialization order in mind.
  3. Thanks for telling me that %M could get the function names. I will have a try.
  4. It does not matter whether I specified const here.

By the way, http://sourceforge.net/p/log4cplus/wiki/Home/ hints that both 1.2.0-RC5 and 1.2.0-RC6 are released. But nothing was changed in https://github.com/log4cplus/log4cplus/releases.

Yours sincerely,
Xiaoshuang

from log4cplus.

wilx avatar wilx commented on May 28, 2024

It would be great if example code posted in http://sourceforge.net/p/log4cplus/wiki/CodeExamples/ is updated. ::log4cplus::initialize() was coped from there.

Good point. I will do that. TBH, I often forget these examples are there. :)

By the way, http://sourceforge.net/p/log4cplus/wiki/Home/ hints that both 1.2.0-RC5 and 1.2.0-RC6 are released. But nothing was changed in https://github.com/log4cplus/log4cplus/releases.

I have no idea how this part of the GitHub web works. Maybe I forgot to push the tags. I use GitHub only for the Git hosting and issues. Everything else is on SF.

from log4cplus.

xiaoshuang-lu avatar xiaoshuang-lu commented on May 28, 2024

Hi Václav, 1.2.0-RC6 in http://sourceforge.net/p/log4cplus/wiki/Home/ and http://sourceforge.net/p/log4cplus/news/2015/11/log4cplus-120-rc6-released/ shall be 1.1.3-RC6. Thanks.

from log4cplus.

wilx avatar wilx commented on May 28, 2024

By the way, http://sourceforge.net/p/log4cplus/wiki/Home/ hints that both 1.2.0-RC5 and 1.2.0-RC6 are released. But nothing was changed in https://github.com/log4cplus/log4cplus/releases.

This should be fixed. I always forget to push the tags.

Hi Václav, 1.2.0-RC6 in http://sourceforge.net/p/log4cplus/wiki/Home/ and http://sourceforge.net/p/log4cplus/news/2015/11/log4cplus-120-rc6-released/ shall be 1.1.3-RC6. Thanks.

This is fixed now.

from log4cplus.

wilx avatar wilx commented on May 28, 2024

I am opening #160 to keep track of the code examples update.

from log4cplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.