Base solution for your next web application
BLACK FRIDAY
From Nov 21
To Dec 1
XXDAYS : XXHRS : XXMIN : XXSEC
SAVE UP TO$3K
Also valid for the
existing customers!
Open Closed

Javascript Logging #722


0
terrybentley created

I would like to log javascript errors and warnings to Log4Net with the other errors generated that are already going to the SQL Server and File system via Log4Net. The boilerplate documentation in the Javascript Logging API section says "These functions write logs to browser's console by default. But you can override/extend this behaviour if you need" but doesn't say how to do it.

Does anyone know how I would go about logging to Log4Net?

Thanks... Terry


2 Answer(s)
  • 0
    hikalkan created
    Support Team

    Hi,

    Overriding a javascript method is simple. Just set it to a new function. Logging methods are defined here: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Resources/Abp/Framework/scripts/abp.js#L165">https://github.com/aspnetboilerplate/as ... bp.js#L165</a>

    You can override it like that:

    abp.log.log = function (logObject, logLevel) {
            //TODO: send logObject to the server...
        };
    

    since all other log methods using abp.log.log, it's enough to override it.

  • 0
    terrybentley created

    Thanks you for your quick response (as always)!

    I was thinking that was all that was required but was not sure of the unexpected repercussion of overriding.

    I should then be able to just do an Async Ajax call to the Log table and on failure write to the console log.