How ELMAH can log Jayrock exceptions

22 views
Skip to first unread message

Eduardo Guardiola

unread,
Nov 6, 2015, 6:04:54 AM11/6/15
to Jayrock
Hi Atif,

The exceptions produced calling JayRock's rpc methods aren't logged by ELMAH, instead they are sent to the client including stacktraces.

I only want to send the exception Message to the client and the exception to be logged by ELMAH...

Can you help on this?

Atif Aziz

unread,
Nov 7, 2015, 5:36:58 AM11/7/15
to jay...@googlegroups.com
Stack traces are only included and sent to the client if the request is local (within the same host).

Errors won't be logged to ELMAH because they are not unhandled, so to speak. They are “handled” on the server and transmitted back to the client as the response. What you can do is register your own subclass of JsonRpcDispatcher and override the OnError method to then log to ELMAH. I have published a gist showing your just how to do that. You can download and run the file in LINQPad.

- Atif



--
You received this message because you are subscribed to the Google Groups "Jayrock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jayrock+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Edu

unread,
Nov 10, 2015, 5:05:10 PM11/10/15
to jay...@googlegroups.com
Many many thanks. The support you bring to your projects is awesome. :-)

Edu

unread,
Nov 18, 2015, 3:49:59 PM11/18/15
to jay...@googlegroups.com
Hi Atif,

Following your directions it easy to log jayrocks exceptions into ELMAH but it seems the form data of the rpc calls isn't being logged (raw XML is not showing it either). ¿Do you think it is expected in this context ? Can be added someway?

Atif Aziz

unread,
Nov 18, 2015, 3:54:37 PM11/18/15
to jay...@googlegroups.com
Hi,

Yes, that's quite normal. A JSON-RPC call is not “forms data”. In other words, it's not a POST where the Content-Type header specifies application/x-www-form-urlencoded.

- Atif

Edu

unread,
Nov 18, 2015, 4:10:00 PM11/18/15
to jay...@googlegroups.com
What i'm trying to log is the json request payload with the rpc method and parameters. No way? :-/

Atif Aziz

unread,
Nov 18, 2015, 5:44:30 PM11/18/15
to jay...@googlegroups.com
Here's the problem, a JSON-RPC request is in the HTTP body, which is represented as a stream. Once this stream has been consumed, such as by Jayrock to call your service, it cannot be rewound by something like ELMAH to be read again for logging. You would need to buffer the stream & then customize Jayrock & ELMAH through their various extensibility points to use the buffered input.

- Atif

Edu

unread,
Nov 19, 2015, 2:42:20 AM11/19/15
to jay...@googlegroups.com
I see.. :-/ thanks for your help!
Reply all
Reply to author
Forward
0 new messages