1
Vote

log2conosle remoting appender for log4net doesnt work

description

i have the following app.config:


<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="S3Logger.log"/>
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
<appender name="RemotingAppender" type="log4net.Appender.RemotingAppender" >
<sink value="tcp://localhost:7070/LoggingSink" />
<lossy value="false" />
<bufferSize value="1" />
</appender>
<!-- Setup the root category, add the appenders and set the default level --> <root>
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="RemotingAppender" />
</root>
</log4net>


for some reason i get the logging only in file but not via log2console ".net remoting reciever" any idea why?

(i am using vs2012 and log4net installed via nuget)

My sample code:

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

namespace Log4NetLog2ConsoleTest1
{
class Program
{
    static void Main(string[] args)
    {
        var log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        while (true)
        {
            log.Debug("Test1 - Debug" + DateTime.Now.ToString());
            System.Threading.Thread.Sleep(300);
            log.Info("Test1 - Info" + DateTime.Now.ToString());
            System.Threading.Thread.Sleep(300);
            log.Error("Test1 - Error" + DateTime.Now.ToString());
            System.Threading.Thread.Sleep(300);

        }
    }
}
}


log2Console configuration:

.Net Remoting: Append Host Name to Logger: True Remote sink name: LoggingSink Remote TCP Port Number: 7070


By the way, the application used the log4net version is 1.2.11.0

comments

MrHIDEN wrote Apr 14, 2016 at 9:35 AM

I have the same problem with 1.6.0.2

I tested it with some fake server and application sends some text stream. But log2console does not show and message.

AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>  
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>  
  <log4net>    
    <appender name="RemotingAppender" type="log4net.Appender.RemotingAppender" >
      <sink value="tcp://localhost:7070/LoggingSink" />
      <lossy value="false" />
      <bufferSize value="1" />
    </appender>    
    <root>
      <level value="ALL" />
      <appender-ref ref="RemotingAppender" />
    </root>    
  </log4net>  
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>  
</configuration>
Program.cs
        static readonly ILog log;

        static Program()
        {
            log = LogManager.GetLogger("Main");
        }

        static void Main(string[] args)
        { 
            log.Info("Test");
            log.Debug("Test");
.NET Remoting in Log2Console is set.

Any suggestion?