Duplicate messages with logstash and log4net RollingFileAppender

Hello,
My app writes events using log4net with rolling file appender.
I get messages duplicated in the file gerenated by logstash.
I found the issue mentioned also here
However, I am not sure about the solution.
Could any one assist ?

cam logstash work with log4net RoolingFileAppender ?
what is the right way to configure logstash file input plugin in that way ?

Adding the log4et appender:


  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value=".\App.log" />
    <appendToFile value="true" /> <!-- true-->
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="2" /> <!-- 100-->
    <maximumFileSize value="1Mb" /> 
    <!-- 10Mb-->
    <staticLogFileName value="true"/>
    <preserveLogFileNameExtension value="true"/>
    <layout type="log4net.Layout.XmlLayout" />
    <filter type="log4net.Filter.levelRangeFilter">
      <levelMin value="INFO" />
    </filter>
  </appender>


adding logstash config


``
input
{
  	file
  	{
		path 		=> "./App.log"
		codec => multiline 
		{
			pattern 	=> "^<log4net:event "
			negate 		=> true
			what 		=> previous
		}
	}
}
filter 
{
	xml 
	{
		source 			=> "message"	
		remove_namespaces 	=> true
		force_array 		=> "false"
		xpath 			=> 
		{
			"/event/message/text()" => "LogMessage"
					
		}
		store_xml 		=> false
  	}
}
output
{
     csv    { 
            fields => ["LogMessage"]
            path   => "c:\dockers\logstash\logstash-8.11.2\config\demo099b_xml_output.csv"
          }   

}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.