Re: ExtendedAccessLogValve.class overloaded timezone and set it to GMT

2017-01-24 Thread Farhan Tariq
Hello chris,

Yes we are facing the exact behavior as mentioned by you

"2017-01-23 04:59:58 Something happened
2017-01-23 04:59:59 Something happened
2017-01-24 05:00:00 Something happened
2017-01-24 05:00:01 Something happened"

The changes made to set timezone to system default only effective for time.
We are only operating in GMT+5 and shipping tomcat logs to different
solutions including SIEM in real-time. So we are purely depending on tomcat
to write the logs with correct date time at first.

I will try to play around with suggestion recommended by you and will let
you know about the outcome.

Thanks
Farhan Tariq

On Mon, Jan 23, 2017 at 8:38 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Farhan,
>
> On 1/21/17 2:20 AM, Farhan Tariq wrote:
> > hi,
> >
> > we have tomcat 7.0.68 deployed on linux.
> >
> > To capture the log in local system timezone using
> > ExtendedAccessLogValve class we change the following line
> > "currentTimestampFormat.setTimeZone(TimeZone.getTimeZone("GMT"))"
> >
> > into "currentTimestampFormat.setTimeZone(TimeZone.getDefault())"
> >
> > in ElementTimestampStruct class and then compile and replace the
> > catalina.jar in already deployed tomcat.
> >
> > Now , The time is sync with the system set time which is GMT+5 but
> > somehow date is still operating on GMT as date get changed at 05:00
> > AM ( system time). please help me in this regard to understand why
> > the above mentioned change have no impact of date field.
>
> Are you saying that at 05:00, the timestamps in your log file look
> like this:
>
> 2017-01-23 04:59:58 Something happened
> 2017-01-23 04:59:59 Something happened
> 2017-01-24 05:00:00 Something happened
> 2017-01-24 05:00:01 Something happened
>
> ?
>
> What does TimeZone.getDefault() return in your environment?
>
> The java.util.Date object in ExtendedAccessLog recons time using only
> the epoch time (milliseconds since 1970 in GMT), and always deals with
> it as a long integer value. Only the DateFormat should be making any
> interpretation at all as to how to format the date.
>
> However, the value of that date only changes once per INTERVAL
> milliseconds, and it changes based upon the GMT date. So your
> experience is expected given the code.
>
> Your attempt to change the time zone to something non-GMT isn't
> compatible with the performance optimizations that have been made to
> that class. If you want to completely change the time zone from GMT to
> e.g. GMT+5, then you'll need to adjust the epoch time stored in
> currentTimestamp by setting it forward by 5 hours.
>
> A single adjustment is not adequate, because the date value coming
> from the request for logging will be off by 5 hours each time, and
> that value is used to update the cached value.
>
> I don't believe it is going to be easy for you to change the time zone
> with such a simple change to your code. You will need to add the
> timezone adjustment each time a calculation is performed. For example:
>
> // ExtendedAccessLog.java:217 (tc9/trunk)
> long millis = eds.currentTimestamp.getTime();
> if (date.getTime() > (TZ_ADJ + millis + INTERVAL -1) ||
> date.getTime() < (TZ_ADJ + millis)) {
> eds.currentTimestamp.setTime(
> date.getTime() - (date.getTime() % INTERVAL) +
> TZ_ADJ);
> eds.currentTimestampString =
>
> eds.currentTimestampFormat.format(eds.currentTimestamp);
> }
>
> You will have to set the value of TZ_ADJ to be 5hrs, or you could
> compute it from TimeZone.getDefault(). Note that it won't adjust for
> DST or anything like that. I'm not sure if that's a problem for you.
>
> I'm curious... what's wrong with GMT?
>
> - -chris
>
> > On Thu, Dec 15, 2016 at 3:31 AM, Konstantin Kolinko
> > <knst.koli...@gmail.com> wrote:
> >
> >> 2016-12-14 18:48 GMT+03:00 Farhan Tariq
> >> <farhantar...@gmail.com>:
> >>> Hello team,
> >>>
> >>> I am not sure why the timezone is explicitly set to GMT in
> >>> ExtendedAccessLogValve class? To capture URL encoded parameters
> >>> I looking to use this class but need
> >> help
> >>> to get time in GMT+5. I am using tomcat 7 on redhat. Any
> >>> suggestions?
> >>
> >>
> >> 1. Please read the mailing list rules:
> >> http://tomcat.apache.org/lists.html#tomcat-users
> >>
> >> You have not mentioned what exact version of Tomcat you are using
> 

Re: ExtendedAccessLogValve.class overloaded timezone and set it to GMT

2017-01-20 Thread Farhan Tariq
hi,

we have tomcat 7.0.68 deployed on linux.

To capture the log in local system timezone using ExtendedAccessLogValve
class we change the following line
"currentTimestampFormat.setTimeZone(TimeZone.getTimeZone("GMT"))"

into
"currentTimestampFormat.setTimeZone(TimeZone.getDefault())"

in ElementTimestampStruct class and then compile and replace the
catalina.jar in already deployed tomcat.

Now , The time is sync with the system set time which is GMT+5 but somehow
date is still operating on GMT as date get changed at 05:00 AM ( system
time). please help me in this regard to understand why the above mentioned
change have no impact of date field.

Regards
Farhan

On Thu, Dec 15, 2016 at 3:31 AM, Konstantin Kolinko <knst.koli...@gmail.com>
wrote:

> 2016-12-14 18:48 GMT+03:00 Farhan Tariq <farhantar...@gmail.com>:
> > Hello team,
> >
> > I am not sure why the timezone is explicitly set to GMT in
> > ExtendedAccessLogValve class?
> > To capture URL encoded parameters I looking to use this class but need
> help
> > to get time in GMT+5. I am using tomcat 7 on redhat.
> > Any suggestions?
>
>
> 1. Please read the mailing list rules:
> http://tomcat.apache.org/lists.html#tomcat-users
>
> You have not mentioned what exact version of Tomcat you are using (1.)
>
> 2. Use of GMT in ExtendedAccessLogValve is by design.
>
> That valve implements log format specified by "Extended Log File
> Format" specification by W3C, and the specification dictates that the
> time is in GMT.
>
> http://tomcat.apache.org/tomcat-8.5-doc/config/valve.
> html#Extended_Access_Log_Valve
>
> https://www.w3.org/TR/WD-logfile.html
>
>
> It may be good to implement configurable timezone in AccessLogValve
> (currently it uses TimeZone.getDefault()), but I think that
> ExtendedAccessLogValve shall remain with GMT.
>
> Best regards,
> Konstantin Kolinko
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


ExtendedAccessLogValve

2017-01-19 Thread Farhan Tariq
Hello Team,

we have tomcat 7.0.68 deployed on linux and start using
ExtendedAccessLogValve.class. To capture the log in local system timezone
we change the following line
"currentTimestampFormat.setTimeZone(TimeZone.getTimeZone("GMT"))"

into
"currentTimestampFormat.setTimeZone(TimeZone.getDefault())"

in ElementTimestampStruct class and then compile and replace the
catalina.jar in already deployed tomcat.

Now , The time is sync with the system set time which is GMT+5 but somehow
date is still operating on GMT as date get changed at 05:00 AM ( system
time). please help me in this regard to understand why the above mentioned
change have no impact of date field.

Thanks
Farhan Tariq


ExtendedAccessLogValve.class overloaded timezone and set it to GMT

2016-12-14 Thread Farhan Tariq
Hello team,

I am not sure why the timezone is explicitly set to GMT in
ExtendedAccessLogValve class?
To capture URL encoded parameters I looking to use this class but need help
to get time in GMT+5. I am using tomcat 7 on redhat.
Any suggestions?

Thanks
Farhan


Fwd: ExtendedAccessLogValve return time in GMT

2016-12-13 Thread Farhan Tariq
Dear Team,

I just started using ExtendedAccessLogValve to log some parameters, but
this class return time in GMT where as we are operating @ GMT+5. Please
guide me how I can write my logs in GMT+5 using ExtendedAccessLogValve
class.

Thanks
Farhan