Ryan Lee | 16 Jan 20:50 2009

getAllAppenders returning NULL

Hello,

I am new to log4cxx and have tried searching for an answer to my problem
to no avail.

My application uses log4cxx with different loggers and appenders
configured. Most of those appenders are rolling file appenders. I want
to obtain all of the files that are being written to by all the
different appenders in my system.

Here's what I do.
1. Program startup, reset the logger configuration:
LogManager::resetConfiguration()

2. Configure from a file:
PropertyConfigurator::configureAndWatch("myLogConfig",30000);

3. Attempt to obtain the list of all files being used by the appenders.

::log4cxx::LoggerPtr pLogger(log4cxx::Logger::getRootLogger());
::log4cxx::AppenderList appenders = pLogger->getAllAppenders();
for(::log4cxx::AppenderList::const_iterator iter = appenders.begin();
	iter != appenders.end();
	++iter)
{
	::log4cxx::FileAppenderPtr pFileAppender(*iter);
	if(pFileAppender != 0)
	{
		// Valid file appender
		std::string logFile(pFileAppender->getFile());
(Continue reading)

Daniel Cohen-Sason | 28 Jan 22:47 2009
Picon

SocketAppender does not reconnect

Hi.
I was able to use SocketAppender by connecting it to Log4J's ServerSocket.
I was expecting that if I turn off the ServerSocket, and then activating it back, my SocketAppender would reconnect to the ServerSocket.
In fact, it doesn't happen.
 
My question is: Does an application using SocketAppender should be able to automatically reconnect to to a SocketServer?
 
(There are some situations where I start my SocketServer *after* the SocketAppender's application already started)
 
This is my appender's configuration:
  
 <appender name="MySocketAppender" class="org.apache.log4j.net.SocketAppender">
    <param name="RemoteHost" value="127.0.0.1"/>
    <param name="Port" value="5681"/>
    <param name="ReconnectionDelay" value="5681"/>
    <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="'%m%n'"/>
        <param name="append" value="true"/>
    </layout>
</appender>
 
Thanks.
 
Ben.NASATYR | 29 Jan 12:50 2009

PatternLayout dates

Hi all,
 
        apologies in advance if I'm being ignorant, as I'm new to this…
 
        I'm using log4cxx on Windows and trying to use PatternLayout to control the formatting of dates. Previously I was using log4cxx 0.9.7 and log4cxx 0.10.0 with visual c++ 7.1 and patterns such as %d{%d %b %Y %H:%M:%S:%Q} were working as expected (this one generates 29 Jan 2009 11:22:04:026).
 
        Recently I have been trying to use log4cxx 0.10.0 with visual c++ 9.0 and encountering https://issues.apache.org/jira/browse/LOGCXX-308. So I went to the documentation for the PatternLayout at http://logging.apache.org/log4cxx/apidocs/index.html and found this about the %d conversion character:
 
Used to output the date of the logging event. The date conversion specifier may be followed by a set of braces containing a date and time pattern string compatible with java.text.SimpleDateFormat, ABSOLUTE, DATE or ISO8601. For example, d{HH:mm:ss,SSS}, d{dd MMM yyyy HH:mm:ss,SSS} or d{DATE}. If no date format specifier is given then ISO8601 format is assumed.
 
This is very different from what worked before so I decided to test it (in log4cxx 0.10.0 and vc 7.1) and got the following results:
 
        Pattern                         Output
 
        %d{ISO8601}                             2009-01-29 11:23:38,073
        %d{ABSOLUTE}                    11:22:59,136
        %d{DATE}                                29 Jan 2009 11:19:11,448
        %d{HH:mm:ss,SSS}                        HH:mm:ss,SSS
        %d{dd MMM yyyy HH:mm:ss,SSS}    dd MMM yyyy HH:mm:ss,SSS
 
        Can anyone advise as to why the last two aren't giving the results expected? What I'm doing wrong? To be honest, either ISO8601 or DATE will be fine for us but I'm just puzzled as to why I can't get the last two working.
 
        With many thanks,
 
                Ben Nasatyr
 
 
 
*********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com ***********************************************************************************

Gmane