Hi all,

1. Can AsyncAppender forward the log messages to a SocketAppender??

I configured a SocketAppender alone and it works fine with the SocketServer. I am 
listening to the events and logging them to a File.
But when I configure the SocketAppender in an AsyncAppender then the file 
are created without any entry in that. 

The problem is as follows,

I am configuring a AsyncAppender which forwards the log messages to a 
SocketAppender and a RollingFileAppender.

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";> 
<appender name="ASYNC-FOO" class="org.apache.log4j.AsyncAppender">
                <param name="LocationInfo" value="true" />
                <param name="BufferSize" value="5" />
                <appender-ref ref="rappender" />
                <appender-ref ref="sappender" /> 
        </appender>

        <appender name="sappender" 
class="org.apache.log4j.net.SocketAppender"> 
                <param name="RemoteHost" value="AC49101063"/> 
                <param name="Port" value="12345"/>
                <param name="LocationInfo" value="true"/> 
        </appender> 
        <appender name="rappender" 
class="org.apache.log4j.RollingFileAppender"> 
                <param name="File" value="serverLog.txt"/> 
                <param name="Append" value="true"/>
                <param name="MaxFileSize" value="1KB"/>
                <param name="MaxBackupIndex" value="10"/>
                <layout class="org.apache.log4j.PatternLayout"> 
                        <param name="ConversionPattern" value="%d [%t] %p 
- %m%n"/> 
                </layout> 
        </appender> 

<root> 
        <priority value ="debug"/> 
        <appender-ref ref="ASYNC-FOO"/> 
</root> 

</log4j:configuration>  

I configure the above file using  the DOMConfigurator.

DOMConfigurator.configure("async12.xml");

I log the messages shown below ,

logger.error("This is message 1");
logger.error("This is message 2");

The message 1 is logged through the RollingFileAppender, and nothing 
happens after that.

When i change the configuration like

                <appender-ref ref="sappender" />
                <appender-ref ref="rappender" /> 
Then nothing gets logged.

If i remove the <appender-ref ref="sappender" /> then everything works fine with the 
RollingFileAppender.

What is wrong with the configuration??
Does AsyncAppender and SocketAppender work together just with the 
configuration? 

Thanking you in advance

Regards
Girish

Reply via email to