Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Rollover of logs


#1

Hi

We are using smart inspect and have been noticiing that the roolover of logs seems to be based on UTC and not local time. ?

Is there a way we can force rollover at local time ie midnight.

Our connections string is
"tcp(reconnect=true,async.enabled=true,reconnect.interval=10),Text(append=true, async.enabled=true, filename=" & IO.Path.Combine(LogFilePath, LogFileName) & “,maxparts=1, indent=true, reconnect=true, rotate=daily, pattern=[%timestamp%] %logentrytype% %session%[%thread%] : %title% )”

Thanks


#2

Hello Andrei,

Thanks for your post. There’s currently no option to use the local time in log file names instead of UTC. The reason for using UTC is that it’s independent of time zone and especially daylight saving changes (which may cause issues for long running applications otherwise).

Regards,
Tobias


#3

Is there any way where we can intercept the rollover and file name logic of Smart inspect as our previous library (home grown) had all of these features

I am happy to share this code with you if you like ?
Thanks

Andrei


#4

There’s currently no way to intercept and customize this specific feature but you can always add and use your own custom file protocol implementation. It’s a bit of work but you could use the existing FileProtocol as reference (we also have an article which explains how to write custom protocols: http://www.gurock.com/smartinspect/using-custom-protocols-with-the-smartinspect-libraries.a.html)

However, I think we will add an option for using UTC or local time to the next version and if this is a non-critical issue for you, I would just recommend waiting for the next release.

Regards,
Tobias


#5

Thanks
The link seems to be broken - 404 error
Do you have an Eta on the new cersion , weeks, months or years ?

Andrei


#6

The link works now, sorry. We currently do not have an eta, but definitely not years. :slight_smile:

As another alternative to writing a custom protocol, you could also modify the library itself (it’s just changing 2-3 lines from DateTime.UtcNow to DateTime.Now) and recompile it. Let me know in case you want to do this. Of course, the problem with this option is that you need to reapply your changes for every update that comes out.

Regards,
Tobias


#7

Thanks . I will give it a try


#8

Hi Andrei,

I will prepare a full diff with the necessary changes until tomorrow. It’s basically just changing DateTime.UtcNow to DateTime.Now but there is one other location that needs to be modified as well and which is a bit more complicated.

Regards,
Tobias


#9

Hi Andrei,

here’s the promised diff:

[code]FileProtocol.cs, line 627:

  • if (this.fRotater.Update(DateTime.UtcNow))
  • if (this.fRotater.Update(DateTime.Now))

FileHelper.cs, line 172:

  • DateTime.UtcNow.ToString(DATETIME_FORMAT),
  • DateTime.Now.ToString(DATETIME_FORMAT),

FileHelper.cs, lines 116-117:

  • Int32.Parse(values[5]) /* Second */
  • Int32.Parse(values[5]), /* Second */
  • DateTimeKind.Local[/code]

I’ve tested the changes and they work as expected. Hope this helps.

Regards,
Tobias