Jetty

Bad in the date output for NCSARequestLog

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 6.1.11
  • Fix Version/s: 6.1.15.rc4
  • Component/s: None
  • Labels:
    None
  • Environment:
    JDK 1.5 + Locale: FRENCH
  • Number of attachments :
    1

Description

NCSARequestLog.java (in package org.mortbay.jetty) uses following variable:

private Locale _logLocale = Locale.getDefault();

Unfortunatly, the date is formatted with the locale of the user which is not correct for WEBALIZER (see: http://www.webalizer.org/). They are NOT compatible because it must use (as other programes) English format. My proposal is to patch the code as follow:

private Locale _logLocale = Locale.ENGLISH;

and to add a getter & a setter for this value. It will resolve my issue (:

Webalizer V2.01-10 (Linux 2.6.18-xenU) locale: C
Using logfile STDIN (clf)
Using GeoIP database /usr/share/GeoIP/GeoIP.dat
Creating output in /srv/d_oxande/www/oxande.com/htdocs/stats
Hostname for reports is 'oxande'
Reading history file... webalizer.hist
Warning: Truncating oversized date field
Warning: Truncating oversized referrer field
Error: Skipping record (bad date): [25/janv./2009:18:03:05 +000 [1]
Generating report for January 2009
Generating summary report
Saving history information...
427 records (1 bad) in 1.00 seconds, 427/sec

Activity

Hide
David Yu added a comment -

If your'e running jetty embedded, simply execute this before anything else:

Locale.setDefault(Locale.ENGLISH);

If standalone, add this as the first element of your jetty.xml (after <Configure>):

<Call class="java.util.Locale" name="setDefault">
  <Arg>
     <New class="java.util.Locale">
       <Arg>en</Arg>
       <Arg>US</Arg>
     </New>
  </Arg>
</Call>

We could prolly add a locale param in the constructor.
But I believe the samples above should work you.

Cheers

Show
David Yu added a comment - If your'e running jetty embedded, simply execute this before anything else:
Locale.setDefault(Locale.ENGLISH);
If standalone, add this as the first element of your jetty.xml (after <Configure>):
<Call class="java.util.Locale" name="setDefault">
  <Arg>
     <New class="java.util.Locale">
       <Arg>en</Arg>
       <Arg>US</Arg>
     </New>
  </Arg>
</Call>
We could prolly add a locale param in the constructor. But I believe the samples above should work you. Cheers
Hide
William Rey added a comment -

Thank you for your help.

After a deeper analysis of the issue I've opened, I've worked on a rewrite based on a previous work done to log inside my application (as a servlet filter). The code is nearly the same than NCSARequestLog but it is more flexible due to a format analysis.

By default, the locale is set to "ENGLISH" to be compliant with scanners (like webalyser) and the time zone is set to the default one (but can be modified). The format is compatible with the Apache HTTPD notation for log. Basically, it is an "access.log" format but can be modified. I assume the performances should be lesser than the NCSARequetLog.

It has been tested and work properly. You just have to change the "package" name.

Show
William Rey added a comment - Thank you for your help. After a deeper analysis of the issue I've opened, I've worked on a rewrite based on a previous work done to log inside my application (as a servlet filter). The code is nearly the same than NCSARequestLog but it is more flexible due to a format analysis. By default, the locale is set to "ENGLISH" to be compliant with scanners (like webalyser) and the time zone is set to the default one (but can be modified). The format is compatible with the Apache HTTPD notation for log. Basically, it is an "access.log" format but can be modified. I assume the performances should be lesser than the NCSARequetLog. It has been tested and work properly. You just have to change the "package" name.
Hide
Greg Wilkins added a comment -

David,

can you add a Locale setter/getter

thanks

Show
Greg Wilkins added a comment - David, can you add a Locale setter/getter thanks
Hide
David Yu added a comment -

getter/setter added to make locale configurable.

Show
David Yu added a comment - getter/setter added to make locale configurable.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: