Documentation - Parsers
The parsers configuration section is used to define the set of message parsers used by Harvester. A valid parser must implement IParseMessages. Parsers will be evaluated in the order that they are defined in configuration and the first parser that indicates it can parse a given message will be used. If no suitable parser is found, a basic log message will still be rendered.
<parsers>
<parser name="log4net" type="Harvester.Core.Messaging.Parsers.Log4NetParser, Harvester.Core" />
<parser name="log4j" type="Harvester.Core.Messaging.Parsers.Log4JParser, Harvester.Core" />
<parser name="default" type="Harvester.Core.Messaging.Parsers.DefaultParser, Harvester.Core" />
</parsers>
type
An assembly qualified name for a parser type.
Default Value: none.
name
An optional name to identify the parser instance (required if multiple parsers of the same type defined).
Default Value: type.Name.
DefaultParser
Accepts any message as a Trace level message. The default parser should be used as an explicit fallback parser if desired and is typically defined at the end of the parsers section.
<parser name="default" type="Harvester.Core.Messaging.Parsers.DefaultParser, Harvester.Core" />
Log4JParser
For use with NLog, the Log4JParser will parse NLog messages using the XMLLayout or XmlLayoutSchemaLog4j layout.
<parser name="log4net" type="Harvester.Core.Messaging.Parsers.Log4NetParser, Harvester.Core" />
Log4NetParser
For use with Log4Net, the Log4NetParser will parse Log4net messages using the Log4JXmlEventLayout layout.
Note: Due to Log4Net re-writing the xml namespace from log4j to log4net when using XmlLayoutSchemaLog4j, the Log4JParser cannot be used.
<parser name="log4net" type="Harvester.Core.Messaging.Parsers.Log4NetParser, Harvester.Core" />
RegexParser
For use with custom message formats. Multiple regex parsers may be defined in the parsers configuration section if an explicit name is provided.
<parser name="custom" type="Harvester.Core.Messaging.Parsers.RegexParser, Harvester.Core" pattern="" options="" />
options
The comma (,) separated list of RegexOptions that should be used with this regex parser's regular expression.
Default Value: none.
Recommended Value: IgnoreCase, ExplicitCapture, Compiled
pattern
The regular expression used to parse the log message. The pattern may contain one or more of the following named match groups:
- level
- logger
- message
- thread
- username
Default Value: none.