trying to post an existing Json file to a remote web api
we use log4net to produce log files, and have the json extensions for log4net so the file output is as follows
{
"date":"2016-03-18T13:49:36.9504697-04:00","level":
"ERROR",
"appname":"log4net_json.vshost.exe",
"logger":"log4net_json.Program",
"thread":"9",
"ndc":"(null)",
"message":"System.DivideByZeroException: Attempted to divide by zero.\r\n at log4net_json.Program.Main() in c:\\temp\\tryMeOut\\log4net.Ext.J
son.Example-master\\log4net_json\\log4net_json\\Program.cs:line 20"
}
we want to use nxlog to consume the file and post the results to a remote web api that will insert the json values into our database. I have tried loads of variations of config changes and
spent hours on the internet / reading the documentation with no luck. Below is one of the config files I have used, however each time i send it out the i only get the first character of the
the text, the "{" . the rest is missing and will not post
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
LogLevel INFO
<Extension _syslog>
Module xm_syslog
</Extension>
<Input in>
Module im_file
File "C:/temp/WOWLog.xml"
InputType LineBased
SavePos FALSE
ReadFromLast FALSE
Exec if $raw_event =~ /^--/ drop();
Exec $raw_event = replace($raw_event, "\r\n", ";");
</Input>
<Output out>
Module om_http
URL http://localhost:51990/api/LogFile/
# HTTPSAllowUntrusted TRUE
</Output>
<Route 1>
Path in => out
</Route>
Looking for the correct settings for the configuration file.
for sanity I have been able to send the same file to the remote web api via a .net console application with a web client
You are getting a single '{' because im_file treats each line in the input as a separate event - i.e. that's what InputType LineBased is.
You need to use xm_multiline to read and concatenate the indented json into a single event record, this can be done similarly to the xml parsing example with something like this:
<Extension multiline> Module xm_multiline HeaderLine /^{/ EndLine /^}/ </Extension>
Make sure to change InputType so that this is used.