I have a web app and a graylog server. I want to send an ajax message to said Graylog server. The only example they provide is:
curl -XPOST http://graylog.example.org:12202/gelf -p0 -d '{"short_message":"Hello there", "host":"example.org", "facility":"test", "_foo":"bar"}'
That works just fine. However when I do this:
message = '{"host":"hostname","short_message":"short message","full_message":"longer message","facility":"dev"}';
console.log(message);
$.ajax({
url: 'http://X.X.X.X:12201/gelf',
method: 'POST',
data: JSON.stringify(message),
success: function(result, textStatus, jqXHR){
console.log("SF Log posted with result: " + result);
if ( $.isFunction( settings.callback ) ) {
settings.callback.call( this );
}
},
error: function(jqXHR, textStatus, errorThrown){
console.log("SF Log encountered error: " + errorThrown);
},
complete: function(){
console.log('on complete: ' , this.data);
}
});
The message is received in Graylog, but it refuses to process it. It just sits in the journal.
This is my current configuration from a plugin I'm writing so we can log in different areas. I've had crossDomain set to true and I've tried just using $.post, but my environment doesn't let me for some reason. Any ideas what else I can try?