You can also check out the basic help and info page by clicking Help


Simple to use:

Use bower to install

To install log4surejs min library use: bower install log4sure
To install log4surejs min library and wrapper for angular apps use: bower install ng-log4sure

Reference script file asynchronously

            
            
                var _logServer;

                     (function () {
                        var ls = document.createElement('script');
                        ls.type = 'text/javascript'; ls.async = true;
                        ls.src = 'http://your-awesome-domain.com/log4sure.min.js';
                        var s = document.getElementsByTagName('script')[0];
                         s.parentNode.insertBefore(ls, s);
                        ls.onload = function () {
                                  // use your token here.
                                _logServer = new LogServer("use-your-token-here");
                        };
                    })();

            
        

Reference script file via script tag

                
                    // please download and reference it from your domain
                   <script src="http://your-awesome-domain.com/scripts/log4sure.min.js" type="text/javascript"></script>
                
               
            

Basic usage

            
                // for logging text
                _logServer.logText("your log message goes here.")

                // for logging error 
                divide = function (numerator, divisor) {
                    try{
                        if (parseFloat(value) && parseFloat(divisor)) {
                            throw new TypeError("Invalid input", "myfile.js", 12, {value:value, divisor:divisor});
                        } else {
                            if (divisor == 0) {
                                throw new RangeError("Divide by 0", "myfile.js", 15, { value: value, divisor: divisor });
                            }
                        }
                    }catch(e){
                        _logServer.logError(e.name, e.message, e.stack);

                    }
                }
                // another use of logError in window.onerror
                // must be careful with window.onerror as you might be overwriting some one else's window.onerror functionality
                // also someone else can overwrite window.onerror.
                window.onerror = function(msg, url, line,column, err) {
                    // may want to check if url belongs to your javascript file
                    var data = {
                        url: url,
                        line: line,
                        column: column,

                    }
                    _logServer.logError(err.name, err.message, err.stack,data);

                };

                // for custom logs
                var foo = "some variable value";
                var bar = "another variable value";
                var flag = "false";
                var temp = "yet another variable value";

                _logServer.log(foo,bar,flag,temp);

            
        

Frequently asked questions

  • I have set up everything, but the logs are not coming in log4sure website, why?

    Go to Manage tab of your library and click Manage Authorized Users, and make sure your library is public for logging. If you have added limited authorized users, make sure the user you are expecting a log from, is an authorized user.

  • Is log4sure opensource?

    No, log4sure is not an open-source project yet, however it may be in the future. Currently it is developed and maintained by Bhavin Surela.

  • Does it cost me to use this service?

    No. This service is provided as a free service by Bhavin Surela ,however if you like the service, please spread the word.

  • How many logs can I insert for one token/library?

    There is no such limit to how many logs you can insert. However there is a counter per library. This counter includes your text logs, error logs and custom logs. As your counter reaches 50000, you will be notified via email and we will automatically archive your logs. After that your counter of logs will be set to 0 again. Of course, you can archive your logs as per your convenience to avoid automatic archiving.

  • Where do I report bugs?

    You can report bugs here.

  • How do you get ip location data?

    This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com.


Credits

I want to credit some of the pieces that brought together the log4sure.js. These are the essentials that played a big role in the making of log4sure.com
Of course, this is not a complete list - but kudos to all of them whose awesome stuff helped the creation of log4sure.com