Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sequence number #6

Closed
mperdeck opened this issue Mar 9, 2014 · 9 comments
Closed

Add sequence number #6

mperdeck opened this issue Mar 9, 2014 · 9 comments

Comments

@mperdeck
Copy link
Owner

mperdeck commented Mar 9, 2014

When two items get logged right after each other, their JavaScript timestamps may be the same. But there is no guarantee that they arrive at the server in the right order. If this happens when logging parameters on a series of function calls, that can get very confusing.

Have a central sequence number (shared by all appenders) that assigns a seq nbr to all log items in increasing order. That way, each log item has a sequence number that is unique per request.

@mosullivan3
Copy link

Hi Matt, I was playing around with version 2.7.6.0 of JSNLog (I believe that this is the latest available version) and I ran into an issue whereby it appears that individual log messages sent to the server appeared to be out of sequence compared to the console. Has this been fixed in a later version or is there

@mosullivan3
Copy link

Oops ! my keyboard just barfed on me.
My last comment should have ended with, Is there a workaround for this issue ?
Thanks - Michael

@mperdeck
Copy link
Owner Author

mperdeck commented Dec 2, 2014

Hi Michael,

2.7.6 is indeed the latest version. As far as I know, there is no easy workaround.

If this is a big problem for you, you could of course create your own sequence number in your JavaScript and log that with the rest of the log message. However, I can see that this is not a satisfactory solution - this sort of thing should be in the logging package itself.

Your comment meanwhile may prompt me to add a sequence number to the next release. I'm pretty busy at the moment though, so can't promise a timeline.

Alternatively, you could implement sequence numbers in jsnlog.js and send me a pull request :-)

Thanks,

Matt

@mosullivan3
Copy link

Hi again Matt,
Thanks for your timely response. I tried your suggestion of adding a sequence number to my JavaScript code and certainly that's a help if you have a single client but when I have
multiple client's it's just as confusing.
Then I thought if there was a way to distinguish between individual clients, this approach might still work. So I have an additional question for you, is there a way to log the client's ip address with your logging mechanism ?
As to your other suggestion of implementing sequence numbers in jsnlog.js and then sending you a pull request, I wish I had the time, but I have a year end deadline, which by the looks of things now, will bleed well into January :(
In any case, if you do indeed get a chance to implement this feature in the next release of your software, I would greatly appreciate it if you could drop a comment on this page to that effect.
Kind regards - Michael

@mperdeck
Copy link
Owner Author

mperdeck commented Dec 3, 2014

Hi Michael,

You can distinguish between individual clients with request ids:
http://jsnlog.com/Documentation/GetStartedLogging/RequestIds

Matt

@mosullivan3
Copy link

Hi Matt,
I added request ids: as you suggested using the info at the link
http://jsnlog.com/Documentation/GetStartedLogging/RequestIds
In my specific case I am using Log4Net and it barfed big time.
Not only did it not record several individual log messages but
also appeared to be constantly resetting itself, see the partial log below

[BEGIN LOGGING AT 2014-12-03 15:23:24,922]
[END LOGGING AT 2014-12-03 15:23:24,922]

[BEGIN LOGGING AT 2014-12-03 15:23:24,922]
00000000-0000-0000-2500-0080030000fc 2014-12-03 15:23:24,938 [7] DEBUG Angular - #4 selectTab() called with tabNum: 3
[END LOGGING AT 2014-12-03 15:23:24,922]

[BEGIN LOGGING AT 2014-12-03 15:23:24,940]
[END LOGGING AT 2014-12-03 15:23:24,940]

[BEGIN LOGGING AT 2014-12-03 15:23:24,940]
[END LOGGING AT 2014-12-03 15:23:24,940]

[BEGIN LOGGING AT 2014-12-03 15:23:24,940]
00000000-0000-0000-0e00-0080010000f5 2014-12-03 15:23:24,940 [7] DEBUG Angular - #10 StartDate: 12/03/2014 07:23, EndDate: 12/03/2014 15:23
[END LOGGING AT 2014-12-03 15:23:24,940]

[BEGIN LOGGING AT 2014-12-03 15:23:24,943]
[END LOGGING AT 2014-12-03 15:23:24,943]

compared to the previously working log without the request ids

[BEGIN LOGGING AT 2014-12-03 16:32:51,097]
2014-12-03 16:32:51,113 [7] DEBUG Angular - #6 serverTimeZoneOffset: -300, clientTimeZoneOffset: 300
2014-12-03 16:32:51,113 [16] DEBUG Angular - #3 selectTab() called with tabNum: 1
2014-12-03 16:32:51,113 [10] DEBUG Angular - #1 initialize() called.
2014-12-03 16:32:51,113 [8] DEBUG Angular - #5 getMachineList() LastUpdateTime: 2014-12-03T21:32:50.690Z, serverTimeZoneOffsetStr: -05:00:00
2014-12-03 16:32:51,113 [9] DEBUG Angular - #2 getMachineList() called with serverName[localhost]
2014-12-03 16:32:51,128 [10] DEBUG Angular - #9 {"InputParms": {"Siteid":"DC ENGINEERING DEVELOPMENT","Inserterid":"DC1MOS","Jobid":"20020907","Mailrununiqueid":"0BOB1K1.1.1417559212","StartDate":"","EndDate":""}}
2014-12-03 16:32:51,128 [16] DEBUG Angular - #8 getJobSummaryData() called.
2014-12-03 16:32:51,128 [8] DEBUG Angular - #7 selectMachine() called with MachineName: DC1MOS
2014-12-03 16:32:51,128 [7] DEBUG Angular - #10 StartDate: 12/03/2014 08:32, EndDate: 12/03/2014 16:32
2014-12-03 16:32:51,128 [9] DEBUG Angular - #4 selectTab() called with tabNum: 3
2014-12-03 16:32:51,128 [10] DEBUG Angular - #12 {"InputParms": {"Siteid":"DC ENGINEERING DEVELOPMENT","Inserterid":"DC1MOS","Jobid":"","StartDate":"12/03/2014 08:32","EndDate":"12/03/2014 16:32","Sections":"1","NumRows":""}}
2014-12-03 16:32:51,128 [16] DEBUG Angular - #11 getAlarmSummaryData() called.
2014-12-03 16:32:51,128 [9] ERROR Angular - #13 Could not connect to SignalR hub !
2014-12-03 16:32:51,162 [10] DEBUG Angular - #14 getJobSummaryData() LastUpdateTime: Wed Dec 3 16:32:51 EST 2014
2014-12-03 16:32:51,679 [10] DEBUG Angular - #15 getAlarmSummaryData() LastUpdateTime: Wed Dec 3 16:32:51 EST 2014
[END LOGGING AT 2014-12-03 16:32:52,705]

Any ideas why it would be doing this ?

Regards - Michael

@mosullivan3
Copy link

Hi again Matt,
I'm still having a problem with the request id's. Getting back to my earlier question, is there a way to log the client's ip address with your logging mechanism ?
Thanks - Michael

@mperdeck
Copy link
Owner Author

mperdeck commented Dec 5, 2014

Hi Michael,

I've never seen the problems you reported with Log4Net and request ids. Just to make sure, I created a simple demo project that logs via Log4Net and that also uses request ids. It worked fine. I've added it to the jsnlogSimpleWorkingDemos project on Github (look for project "EmptyLog4Net - RequestIds"):
https://github.com/mperdeck/jsnlogSimpleWorkingDemos

In case you keep having problems, could you create a small demo site that reproduces the problem you're seeing and put it on Github. No guarantee I'll be able to solve it, but you never know. The smaller and focused you can make that demo the better.

About getting client IPs:
That's very easy. The .Net server side component generates JS code that sets this on the JL namespace (do a view source on any page that uses JSNLog and look for "JL.setOptions"). In your JavaScript, you can retrieve it with
JL.clientIP
For example:
alert(JL.clientIP);

Regards,

Matt

@mperdeck
Copy link
Owner Author

mperdeck commented Dec 7, 2017

I implemented a sequence number in version 2.25.0. This is unique per request and is always higher for messages that were generated later.

On http://jsnlog.com/Documentation/Configuration/JSNLog look for %entryId
Or on http://js.jsnlog.com/Documentation/DownloadInstall look for "event id"

@mperdeck mperdeck closed this as completed Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants