sort by date

Notes, tips, and other usefull things on how to use LogMX

Moderator: admin

Post Reply
Jack
Posts: 7
Joined: Fri Mar 14, 2014 2:46 pm

sort by date

Post by Jack »

Hi,

I try to sort my log by date, but I have an error message:
Unable to use date filter since this file format (using Log4j pattern "%d{dd MMMM. yyyy HH:mm:ss,SSS} %-5p %-15c{1}: %m") doesn't handle absolute timestamps
Do I have to change something on my parser ?
admin
Site Admin
Posts: 555
Joined: Sun Dec 17, 2006 10:30 pm

Re: sort by date

Post by admin »

Hello Jack,

How do you try to "sort" your logs by date? Because, actually, you can't sort your logs by date, you can only filter them by date.
I tried to use a filter with this Log4j Pattern with entries like:

Code: Select all

22 May. 2014 10:00:00,123   INFO             Emitter: Message1
and it works great if I set the Parser's Locale to "English" (because I used "May" for month). But if I choose "German" for example, it gives me the error message you got.
So please check that you are using the right Locale (in "Tools" > "Options" > "Parsers" > then edit your parser) accordingly to the language used in your logs.

Optionally, if you want to modify your default Locale for other new Parsers you will create (to avoid having to choose it for each parser), you can add

Code: Select all

-Duser.language=<your_language>  -Duser.country=<your_country> 
to:
  • LogMX.bat if you're using it to start LogMX on Windows, just after "SET CMD_LINE=%JVM_OPTIONS%" and just before "-cp"
  • logmx.sh/logmx.command for Linux/Mac on the last line just before "-cp"
(see http://www.oracle.com/technetwork/java/ ... 34809.html for a list of language/countries)

Xavier
Jack
Posts: 7
Joined: Fri Mar 14, 2014 2:46 pm

Re: sort by date

Post by Jack »

Yes sorry, I mean filter!

I have the correct language for my parser, but maybe the problem is with accent? (French language)
Because I must use UTF-8 encoding to have correct display. My file come from an Unix platform with SFTP.

For instance I have some date like that : "09 déc. 2013 15:24:59,269"
admin
Site Admin
Posts: 555
Joined: Sun Dec 17, 2006 10:30 pm

Re: sort by date

Post by admin »

Hello Jack,

OK for the Locale :) . If you do not have trouble with other months like "novembre", then you are right, it may be due to french accent.
But it may also be some other nasty issue with Java date formats: since you're using "MMMM" for the month in your date format, it means that the month name must appear in complete form, not truncated, like "décembre" instead of "déc". Here is a quick example:

Code: Select all

Date date = new GregorianCalendar(2014, 11, 9).getTime(); // 9 dec. 2014
System.out.println(new SimpleDateFormat("dd MMMM. yyyy", Locale.FRENCH).format(date));
System.out.println(new SimpleDateFormat("dd MMM. yyyy", Locale.FRENCH).format(date));
System.out.println(new SimpleDateFormat("dd MM. yyyy", Locale.FRENCH).format(date));
will produce:

Code: Select all

09 décembre. 2014
09 déc.. 2014
09 12. 2014
So you may want to try a date format like "dd MMM yyyy" instead of "dd MMMM. yyyy", without the trailing dot (.) and the fourth "M". Indeed, when the month name is truncated, Java already adds a trailing dot like in "déc.".
Tip: you can test all formats/logs combinations in real-time using the "Parser Test" panel in "Tools" > "Options" > "Parsers" > double-click on your parser.

Please let us know if you still have issues using this parser.
Jack
Posts: 7
Joined: Fri Mar 14, 2014 2:46 pm

Re: sort by date

Post by Jack »

It works !

Thanks for the solution, and sorry for my mistake...
admin
Site Admin
Posts: 555
Joined: Sun Dec 17, 2006 10:30 pm

Re: sort by date

Post by admin »

Pleasure :wink:
"Anyone who has never made a mistake has never tried anything new." (A. Einstein)
Post Reply