Yes may be it's possible. You should try to compile with at least two
threads :
See the example in attachment
Michaël
Dahl, Jon wrote:
Michael,
Are you sure about that, i'm getting the same thread id every time i run the
app. Even if I reboot the machine I get the same thread id. That doesn't make
since.
JD
-----Original Message-----
From: Michaël CATANZARITI [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 12:24 PM
To: Log4CXX User
Subject: Re: Thread Name Issues
Hello Jon,
log4cxx ouputs the thread identifier (cf. function pthread_self) You can get the same id for the main thread, if you execute a test
program several times.
But if you have two or more threads, you should get different ids.
Michaël
Dahl, Jon wrote:
For some reason, log4cxx always outputs the same value for %t. In my
case on the version of Linux I am using, it outputs 8192.
Has anyone else come across this problem before? Is there something I
may not be doing in the config/code?
This is the only thing keeping me from using this lib in our production
code.
Thanks,
JD
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/thread.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
LoggerPtr rootLogger = Logger::getRootLogger();
class LoggingThread : public Thread
{
public:
virtual void run()
{
for (int i = 0; i < 10; i++)
{
rootLogger->info(_T("info message"));
Thread::sleep(100);
}
}
};
int main()
{
int result = EXIT_SUCCESS;
try
{
BasicConfigurator::configure();
ThreadPtr loggingThread = new LoggingThread();
loggingThread->start();
for (int i = 0; i < 10; i++)
{
rootLogger->debug(_T("debug message"));
Thread::sleep(100);
}
loggingThread->join();
}
catch(Exception&)
{
result = EXIT_FAILURE;
}
return result;
}