Giter Site home page Giter Site logo

mperdeck / jsnlog Goto Github PK

View Code? Open in Web Editor NEW
191.0 191.0 38.0 98.14 MB

JSNLog for .Net. Combines jsnlog.js client side logging with .Net server side component to receive log messages and pass them to the server side logging package. Configure loggers in web.config.

Home Page: jsnlog.com

License: MIT License

C# 100.00%

jsnlog's People

Contributors

almenit avatar brase avatar cbpetersen avatar chikkannam avatar dazinator avatar kieranbenton avatar mperdeck avatar terribledev avatar thestonehead avatar thompson-tomo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsnlog's Issues

Buffered log entries to be logged as one log entry

Hello,
thanks for the great library!
I see that the buffered log entries are sent to server as a bunch and saved to log as independent entries. It could be better to save these as one entry (or have an option to do it). It's especially useful if .NET logger (serilog in my case) is set to log only errors which would filter out all the buffered entries lower than error. But I think the idea of buffered messages is most useful in the scenario when I'd add debug/trace entries which will be only sent when an error happens.

Only start logging a message after it has occurred X times

You may want to only send a given message if it happens "a lot" during a given page load. This feature would set a number of regexes (like onceOnly) and only after X messages have matched a given regex will messages matching that regex be sent to the server.

JSNLog & ELMAH - Uncaptured data?

Thanks for the helpful utility, I have a question concerning functionality and assume I've got things fouled up.

I've got my site using JSNLog and ELMAH and errors are being logged. The issue is that I have provided a logger name, but that's not being pushed through to ELMAH, but I do see it in the log request.

I think that I saw request id was deprecated, but I see that value on the log request, but its not in ELMAH either.

Am I looking at a configuration issue or is something else going on?

JSNLog + Elmah - Doesn't Log Fields to DB

Hi there,

I've been trying to configure JSNLog with Elmah logged to a SQL database. I'm running into a problem where the error generated client-side is passed from JSNLog through to Elmah (and the database), however two critical fields remain empty:

Application
Host

The main problem with this is that the Application field is empty, which means Elmah.axd won't display the error on the page. The Host field is of less importance, but would still be helpful. I thought that Elmah would generate and store these fields, and server-side errors have them, but they're missing

image

I have previously used a solution based loosely on the URL below which has both the above fields stored, which leads me to believe it's my configuration. I just can't find documentation on whether this is expected and how to resolve if not.
http://ivanz.com/2011/05/08/logging-javascript-errors-with-elmah/

A secondary issue is that the message stored in elmah is just a dump of the errorObj passed in, as opposed to something formatted. I think this is expected, however.

Any advice on configuration or pointers to material would be appreciated.

Instrument feature for ajax calls

Feature to instrument all ajax calls that use $.ajax.

  • Send INFO log with time it took
  • Or send ERROR log if it took too long + time it took

Filter option by the url of the ajax call (match a regex)

JSNLog.CommonLogging NuGet error

Hi, I get the following error when attempting to install JSNLog.CommonLogging:
'External packages cannot depend on packages that target projects.'
image
Any thoughts?
Thanks.

JSNLog is not working with Classic mode of IIS application Pool

Tried with version 2.7.0.0 There are still problems.

I installed it through visual studio
Worked with IIS express mode
When hosted application with virtual directory through IIS the error was given as ./jsnlog.logger was not found
Changed the entry in jsnlog.js from "/jsnlog.logger" to "jsnlog.logger" (removed "/")
Error was gone but it is not working with classic or integrated mode.

Let me know if you need more information or am i missing anything?

Implement bower.json

Hey guys.

It should be great to implement package.json (NPM) and bower.json (BOWER) to allow user to manage dependencies into project.
I can do the job, just let me know!

Have a good day.

Sample Solution

Is there a sample solution that utilizes JSNLog that can be downloaded to see how everything works all put together. I am having issues putting everything together. I have several logging frameworks that I need to work with server side as well as a few custom ones.

Thanks,
~David

Wrong path in jsnlog.js ?

I am using JSNLog 2.4.0.0 together with MVC5. The client side logging only works when I navigate to the root of my web site. To fix this I had to change line 313 in jsnlog.js from this.url = "jsnlog.logger" to this.url = "/jsnlog.logger" to make the path absolute. Is this a bug in jsnlog.js ?

JL "maxMessages" not working?

I'm testing my PHP version of the server-side code. I have the following sample in my Javascript where I'm testing the maxMessages options, and it doesn't appear to be working (or stopping the messages from being sent):

<script language="javascript">
var appender= JL.createAjaxAppender();
appender.setOptions({"url":"jsnlog.logger.php"});
JL().setOptions({"appenders": [appender]});

JL.setOptions({"maxMessages":"2"});

</script>
<script language="javascript">
    JL().info("Info message sent from JSNLog");
    JL().warn("Warn message sent from JSNLog");
    JL().error("Error message sent from JSNLog");
</script>

When I load the page, Firebug shows all 3 messages being sent to the backend.

Do I have the Javascript setup incorrectly? The other JL.setOptions() variables seem to work ok (for instance, I can set the requestId without issue) it's only the maxMessages that seems to be having problems.

Thanks, and apologies if I've misread something in the docs.

pnellesen

404 Not Found Error when using IIS (7.5) but ok with VS Development Server (if not IE)

Hi,
When I run my MVC 5.1.2 (Razor 3.1.2) application via Visual Studio 2012, JSNLog doesn't work and fails with errors: "Failed to load resource: the server responded with a status of 404 (Not Found)" and "POST http://localhost/jsnlog.logger 404 (Not Found) " if I use IIS(7.5). If I change my project to use the Visual Studio Development Server, it works. I have another MVC project where JSNLog works using IIS and both applications are using the same Applicaiton Pool in IIS.

Please note that when using IE 9 as a browser, it doesn't work in IIS or the Visual Studio Development Server.

I am running Windows 7 64-bit and both applications are set up as Virtual Directories off the Default Website in IIS.

Please help,

Exception with Visual Studio 2013 and .NET Framework 4.5

I am trying to get JSNLog working with an MVC5\WebApi2 project in Visual Studio 2013. I have installed NLog, Common, Common.NLog and JSNLog using Nuget, and I have combed through the EmptyNLog sample and everything looks identical to my configuration. I can successfully log to NLog directly on the server.

When I try to perform a JL().info('message'). an error is thrown on the client:

Failed to load resource: the server responsed with a status of 500 (Internal Server Error).

Using Fiddler, I can see the following post being sent to http://localhost/jsnlog.logger

{"lg":[{"l":3000,"m":"message","n":"","t":1385426728291}]}

The following error details are being returned:

[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary`2.get_Item(TKey key) +10629801
JSNLog.LogHandling.LoggerProcessor.ProcessLogRequestExec(String json, String userAgent, String userHostAddress, DateTime serverSideTimeUtc, String url, XmlElement xe) +160
JSNLog.LogHandling.LoggerProcessor.ProcessLogRequest(String json, String userAgent, String userHostAddress, DateTime serverSideTimeUtc, String url) +124
JSNLog.LoggerHandler.ProcessRequest(HttpContext context) +385
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

Any ideas?

Saying Hello

I noticed you're looking for a PHP server-side implementation for JSNLog. I've written up a very rough and simple proof-of-concept that can accept the log messages from JSNLog and write it to the default Apache server error log file. This is for PHP 4+ running on Linux. As I flesh this out I plan to add Log4j capability as well.

Source can be found at https://github.com/pnellesen/JSPHPLog. Still in the very early stages as this is my first GitHub project, so any suggestions/criticisms welcomed :)

Source for adapters

Hello!

I am not happy the way the elmah hook is writing the exceptions to elmah (all on 1 line as a json object) so I wanted to change it, but I can't find the source anywhere for it.

Could you release the source for the adapters as well?

Thanks!

MVC @Html.ActionLink Misformed when adding "jsnlog.logger" route to routetable in PostStart

Hello,

I'm playing around in your example project "EmptyElmah". But I think I found a problem.

When you simply add the following div to Index.cshtml:

< div>
@Html.ActionLink("Test", "Test", "Home")
< /div>

the result will be

< div>
< a href="/jsnlog.logger?action=Test&controller=Home">Test
< /div>

If you uncheck the line in void PostStart:
RouteTable.Routes.Insert(0, new Route("jsnlog.logger/{*pathInfo}", new StopRoutingHandler()));

This is the result (as expected):
< div>
< a href="/Home/Test">Test
< /div>

Is this related to MVC (or VS2013)?
Do you know what is causing this problem?

Kind regards,
ProblemSolved

Enterprise Library 6 Supported?

I am unable to find information regarding support for Enterprise Library on the site. Is there support for Enterprise Library 6 or what would be the recommended approach for that?

Thanks,
~David

Wrong Common.Logging version for JSNLog.Log4Net

I've installed JSNLog.Log4Net version 2.7.2, which supposedly has a dependency on Common.Logging version >= 2.2.0, which is the version of Common.Logging I have installed. However, when I try to use JSNLog, I get the following runtime error:

Could not load file or assembly 'Common.Logging, Version=2.1.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Any thoughts?

Instrument feature for functions

Feature that allows you to instrument all functions in a namespace (which is a variable containing an object that contains members of type function). Option to only instrument those functions whose names match one of a list of regexs (only works if the functions are not anonymous).

Instrumentation options:

  1. surround with try catch (catch exception, log it, rethrow with a flag saying it has been logged to prevent relogging)
  2. log parameter values (DEBUG logger)
  3. try finally to measure execution time of the function

JSNLog.Elmah and Common.Logging 2.1.2

I have Common.Logging 2.2.0 installed.

JSNLog dependency with Common.Logging is >= 2.1.2. So that install fine.
JSNLog.Elmah dependency with Common.Logging is = 2.1.2. Hence it wont install.

Any reason why its dependent on 2.1.2 only?

JSNLog with Elmah looks to succeed but does not log to Elmah

Hi there,

I am trying to get JSNLog to log to Elmah, but it doesn't seem to want to work.

I have used nuget to load in the JSNLOG.Elmah package and have added code to my view to get the javascript into my page.

From the console in my browser, when I do a JL().debug("log message") i see the request go off to the jsnlog.logger and get a 200 status but nothing appears in Elmah.

I would appreciate any guidance you can give about where to go looking for the issue.

Notes:

  • Web.config is at the default config from package installation
  • If I add a consoleAppender client side it works fine, i.e. i see the messages in the console.
  • Running on Windows 8.1.1 with IIS 8.5 in an Integrated mode application pool
  • Website is running .NET 4.5
  • I added the ignore route in my routeconfig
  • the file JSNLogConfig.cs is in App_Start

REQUEST HEADERS:
POST /calumo11/jsnlog.logger HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 105
Cache-Control: no-cache
Pragma: no-cache
Origin: http://localhost
JSNLog-RequestId: f50401b4-96e2-460e-9efe-3f5974e6c4ee
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Content-Type: application/json
Accept: /
Referer: http://localhost/calumo11/view/1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

RESPONSE HEADERS
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
Persistent-Auth: true
X-Powered-By: ASP.NET
Date: Wed, 21 May 2014 14:16:47 GMT
Content-Length: 0

Thanks

James.

Change the URL at runtime?

I looked through the docs and can't figure out how to configure the url to point to my endpoint. I ended up copying the jsnlog.js script and hacking it. It looks as if the setOptions call doesn't support a url parameter. Thanks!

no element found jsnlog.logger:1

I have my website set up similar to what you have there in JSNLogSimpleWorkingDemos.EmptyElmah project but for some odd reason, when it go to run, 19 JavaScript error messages show up with the message "No element Found - Jsnlog.logger: 1".

While running your sample code, i noticed that when defaultAjaxUrl ="" (an empty string), the error message above does not show up. However, when I try the same in my web application, I still get the error messages. Below is the setting I have for the logger in my web.config

What is it that I could have missed here please? Thanks in advance

Bridge to structured loggers

JSNLog currently uses common.logging to interface to server side logging package. Introduce new bridge that supports structured logging as well, such as Serilog.net.

No appender named [ajaxAppender] could be found.

Using log4net and am getting correct output persisted but notice these messages during built:
log4net:ERROR XmlHierarchyConfigurator: No appender named [ajaxAppender] could be found.
log4net:ERROR Appender named [ajaxAppender] not found.

Is there supposed to be an ajaxAppender explicitly declared in web.config? Somewhere in your docs ive seen reference to 'native appender'.

Console log?

Hello,
Can JSNLog write log messages to the browser's built-in console?

Please tag releases

I'd like to package your library using http://www.webjars.org/ but in order to do so I need you to tag each release (as in http://git-scm.com/book/en/Git-Basics-Tagging).

I only need the latest release tagged for now.

PS: I don't understand why you are using branch-per-release instead of a tag per release. Normally you use branch-per-release if you're working on multiple versions in parallel, which you don't seem to be doing.

Buffered log entries could be logged in wrong order with other entries

if I have a buffered entries sent and if there are some other entries with high enough level to be sent on their own immediately after, the entries can be logged in wrong order. I can see the calls to /jsnlog.logger are made in right order, but in the log file entries are not.
Looks like since there are more than one entry in the request payload, processing it on server end takes a bit longer than the queries which has only one entry even though they were sent a bit after.
To confirm the theory, I've added a 1 sec delay to the entries made after the buffered one and all was logged as expected.

Wrong MVC routing with NuGet installation ?

You add the file JSNLogConfig.cs to implement routing for jsnlog.logger but the side effect is that all other routng in MVC file RouteConfig.cs stop working :( My solution was to delete your file JSNLogConfig.cs and add one statment in my existing file RouteConfig.cs: "routes.IgnoreRoute("jsnlog.logger/{*pathInfo}");"

Discussion : Persistent & Offline support ?

Hi !

I'm currently needing some clientside logging allowing :

  • to persist logs somewhere (in localstorage, for instance), in order to be able to "unleash" them when needed (for instance, only when an error occurs, in order to not pollute/load server logging if I have lots of clients)
  • to bufferize logs on a rolling out manner, while not "unleashed" (because localstorage has limited size, I'd like, for instance, to limit to 1MB the persisted logs and roll out changes)
  • to delay ajax call if client is offline

I never used jsnlog yet, but it seems configurable enough to make most of my requirements possible.

Would you agree ?
If you find those feature interesting, I may implement them an provide a PR with them if you help me a bit in implementing them :-)

Cheers,

log.errorException

Hello,
congratulations for the project!!!
can be created a new method? log.errorException?
I wish print an exception in error level.
Thanks!

JSNLog Structured Message

Is there any way to have the %message variable stored into a Document column in MongoDB. Let me explain. Currently I use Serilog and Serilog MongoDB sink with these lines to log data into MongoDB.

image

But, when I look at the data inserted into MongoDB I have this :

image

You see that data is stored as a string. Is there any way to have this information saved as a Document? Is this a limitation because Common.Logging is used. Let me know if there is any workaround.

Thanks.

%newline not work in elmah xml storage

Hi,
Very thanks for jsnlog.

I have this config in web.config:

  <jsnlog serverSideMessageFormat="Request Id: %requestId %newline Url: %url %newline Logger: %logger %newline Level: %level %newline User Host Address(IP): %userHostAddress %newline User Agent: %userAgent %newline  Client UTC Date: %utcDate %newline Server UTC Date: %utcDateServer %newline %newline Message: %newline %message" serverSideLogger="JavascriptLogger">
  </jsnlog>

But %newline not work!
What is problem?

Problems installing in an MVC5 app

Greets - I'm working with an MVC5 app - I've used the Nuget lines for both the base distro and Install-Package Common.Logging.Log4Net1211.

The app uses the standard bundling and minification pattern meaning the master page has loaded a number of libraries before I'm able to insert @Html.Raw(JSNLog.JavascriptLogging.Configure()) at the top of the tag. I've placed a test - JL().fatal("log message"); as high as I can (in the _LoginPartial but F12 tools shows a 404 jsnlog.logger.

Am I needing to insert any code in the BundleConfig?

thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.