Comments (7)
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.
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.
Hi, thanks for your comments.
- It would be great if example code posted in http://sourceforge.net/p/log4cplus/wiki/CodeExamples/ is updated. ::log4cplus::initialize() was coped from there.
static intmax_t dummy = initialize();
has no problems. I have already kept the initialization order in mind.- Thanks for telling me that
%M
could get the function names. I will have a try. - 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.
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.
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.
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.
I am opening #160 to keep track of the code examples update.
from log4cplus.
Related Issues (20)
- How to setup a singleton logger instance HOT 11
- SysLogAppender: header elements should be limited in length
- [Question] Appender for AWS CloudWatch Logs HOT 2
- ./configure fails using c++2a HOT 3
- How to configure PatternLayout to use __FUNCTION__ HOT 7
- A link error occurred while compiling the my program. HOT 4
- Question: Effect of LOG4CPLUS_REQUIRE_EXPLICIT_INITIALIZATION on Windows? HOT 5
- Setting log level through env in log config file HOT 3
- Help needed: how to periodically flush logger with appender's immediateFlush set to false? HOT 2
- log file name not change after rollover TimeBasedRollingFileAppender HOT 3
- log's maxsize>200kb,but it dosen't work HOT 2
- Opentelemetry integration HOT 1
- What kind of compilation options can correctly generate a multi-threaded logging library HOT 5
- Win64 application crash on exit HOT 1
- Why mingw can't complie log4cplus-2.1.1? HOT 1
- Sending logs from log4cplus to log4j via TCP HOT 1
- Is it possible to build log4cplus for QNX aarch64le? HOT 3
- Save all configuration in a file HOT 2
- Question: Which latest version of Log4cplus I should use on RedHat 7.9 with DevToolset11-toolchain ( GCC 11.2 ) compiler HOT 7
- Does not work when maxBackupIndex is set to 0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log4cplus.