# Error parsing xml with XmlSimple / UndefinedNamespaceException: undefined prefix log4j found

**URL:** <https://discuss.elastic.co/t/error-parsing-xml-with-xmlsimple-undefinednamespaceexception-undefined-prefix-log4j-found/314097>\
**Category:** Logstash\
**Created:** [September 9, 2022, 10:44pm UTC](https://discuss.elastic.co/t/error-parsing-xml-with-xmlsimple-undefinednamespaceexception-undefined-prefix-log4j-found/314097 "2022-09-09T22:44:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erwin339](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@erwin339](https://discuss.elastic.co/u/erwin339)\
**Post date:** [September 9, 2022, 10:44pm UTC](https://discuss.elastic.co/t/error-parsing-xml-with-xmlsimple-undefinednamespaceexception-undefined-prefix-log4j-found/314097/1 "2022-09-09T22:44:54Z")

</div>

I am working with local filebeat and logstash and elasticsearch and kibana on a server. I need to convert the information that comes to me from the logs from xml to json. My configuration works when it reads a file with log in xml but when I use a log generator and send them this conversion is never done and it shows me the following message:

**MI LOG**  
\<log4j:event logger="LogGeneratorApp.MainForm" timestamp="1662748734048" level="INFO" thread="1"\>log4j:messageThis is a test log message\</log4j:message\>log4j:properties\<log4j:data name="log4net:UserName" value="TE\60085367" /\>\<log4j:data name="log4jmachinename" value="TAMP00043541" /\>\<log4j:data name="log4japp" value="LogGeneratorApp.exe" /\>\<log4j:data name="log4net:HostName" value="TAMP00043541" /\>\</log4j:properties\>\<log4j:locationInfo class="LogGeneratorApp.MainForm" method="SendToLog" file="" line="0" /\>\</log4j:event\>

**Y EL ERROR EN CONSOLA ES:**

[2022-09-09T13:39:28,195][WARN][logstash.filters.xml][main][119f194f3af434e5618422bbe0983095b06acb780727af330f680c5335d16fe4] Error parsing xml with XmlSimple {:source=\>"message", :value=\>"\<log4j:event logger="LogGeneratorApp.MainForm" timestamp="1662748761483" level="INFO" thread="1"\>log4j:messageTIMER Generated : This is a test log message\</log4j:message\>log4j:properties\<log4j:data name="log4net:UserName" value="TE\60085367" /\>\<log4j:data name="log4jmachinename" value="TAMP00043541" /\>\<log4j:data name="log4japp" value="LogGeneratorApp.exe" /\>\<log4j:data name="log4net:HostName" value="TAMP00043541" /\>\</log4j:properties\>\<log4j:locationInfo class="LogGeneratorApp.MainForm" method="SendToLog" file="" line="0" /\>\</log4j:event\>", :exception=\>#\<REXML::UndefinedNamespaceException: Undefined prefix log4j found\>, :backtrace=\>["uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rexml/parsers/baseparser.rb:414:in `block in pull_event'", "org/jruby/ext/set/RubySet.java:628:in `each'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rexml/parsers/baseparser.rb:412:in `pull_event'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rexml/parsers/baseparser.rb:185:in `pull'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rexml/parsers/treeparser.rb:23:in `parse'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rexml/document.rb:288:in `build'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rexml/document.rb:45:in `initialize'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/vendor/bundle/jruby/2.5.0/gems/xml-simple-1.1.8/lib/xmlsimple.rb:979:in `parse'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/vendor/bundle/jruby/2.5.0/gems/xml-simple-1.1.8/lib/xmlsimple.rb:164:in `xml_in'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/vendor/bundle/jruby/2.5.0/gems/xml-simple-1.1.8/lib/xmlsimple.rb:203:in `xml\_in'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/vendor/bundle/jruby/2.5.0/gems/logstash-filter-xml-4.1.2/lib/logstash/filters/xml.rb:195:in `filter'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/logstash-core/lib/logstash/filters/base.rb:159:in `do\_filter'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/logstash-core/lib/logstash/filters/base.rb:178:in `block in multi_filter'", "org/jruby/RubyArray.java:1820:in `each'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/logstash-core/lib/logstash/filters/base.rb:175:in `multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:134:in `multi\_filter'", "C:/Users/60085367/Documents/Parsing090922/logstash-7.14.0/logstash-core/lib/logstash/java\_pipeline.rb:295:in `block in start\_workers'"]}

**MY LOGSTASH**

```auto
input {
beta {port => 5044}
}
filter{
xml{
source => "message"
target => "doc"
}
}
output{
stdout {codec => rubydebug]
}

```

**MY FILEBEAT**

```auto
filebeat.inputs:
- type: filestream
id: my-filestream
enable: true
path: C:\..........\logs\*
multiline.pattern: ^<log4j:event.*
multiline.negate: true
multiline.match: after

File Modules default settings
Elasticsearch template default setting

Output.logstash: 
host: ["0.0.0.0:5044"]

Processors default
 

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 9, 2022, 11:00pm UTC](https://discuss.elastic.co/t/error-parsing-xml-with-xmlsimple-undefinednamespaceexception-undefined-prefix-log4j-found/314097/2 "2022-09-09T23:00:34Z")

</div>

Update your xml filter to define the log4j namespace

```
namespaces => { "log4j" => "http://www.example.com/" }

```

The "[http://www.example.com/](http://www.example.com/)" will not be referenced, so it does not have to be accessible.

---

<div class="post-metadata">

**Author:** ![erwin339](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@erwin339](https://discuss.elastic.co/u/erwin339)\
**Post date:** [September 12, 2022, 3:07pm UTC](https://discuss.elastic.co/t/error-parsing-xml-with-xmlsimple-undefinednamespaceexception-undefined-prefix-log4j-found/314097/3 "2022-09-12T15:07:09Z")

</div>

For this configuration is there another additional step? definitely the error is in the namespace, I already added the namespace =\> {....} but I still have the same error.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 10, 2022, 3:07pm UTC](https://discuss.elastic.co/t/error-parsing-xml-with-xmlsimple-undefinednamespaceexception-undefined-prefix-log4j-found/314097/4 "2022-10-10T15:07:10Z")

</div>

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