-
15. Re: Logging filter in Jboss as 7.1.1 Final
piyush.mnnit Apr 11, 2013 3:38 AM (in response to jamezp)I mean here is date formatters. Please find log4j documentation below:
" Used to output the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If no date format specifier is given then ISO8601 format is assumed.
The date format specifier admits the same syntax as the time pattern string of the
SimpleDateFormat
. Although part of the standard JDK, the performance ofSimpleDateFormat
is quite poor.For better results it is recommended to use the log4j date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying
AbsoluteTimeDateFormat
,DateTimeDateFormat
and respectivelyISO8601DateFormat
. For example, %d{ISO8601} or %d{ABSOLUTE}.These dedicated date formatters perform significantly better than
SimpleDateFormat
. "Looking for how to get %d{ABSOLUTE} in Jboss logging.
-
16. Re: Logging filter in Jboss as 7.1.1 Final
jamezp Apr 11, 2013 11:57 AM (in response to piyush.mnnit)You can't just use ABSOLUTE or ISO8601 you have to use a format that java.text.SimpleDateFormat can understand. In your case I think ABSOLUTE just renders to HH:mm:ss,SSS.
--
James R. Perkins
-
17. Re: Logging filter in Jboss as 7.1.1 Final
andreypolozov Nov 6, 2013 2:21 PM (in response to jamezp)Trying to use %d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}
Getting error
java.util.logging.ErrorManager: 5: Formatting error
java.lang.IllegalArgumentException: Illegal pattern character 'T'
This seems to be working: %d{yyyy-MM-dd}T%d{HH:mm:ss.SSSZ}
But it's not quite right: time zone doesn't have ":" in the middle)
And doesn't seem to be most efficient: SimpleDateFormatter is used twice...
-
18. Re: Logging filter in Jboss as 7.1.1 Final
jamezp Nov 6, 2013 3:41 PM (in response to andreypolozov)It seems to work fine for me. Is there a stack trace with it?
--
James R. Perkins
-
19. Re: Logging filter in Jboss as 7.1.1 Final
andreypolozov Nov 6, 2013 5:26 PM (in response to jamezp)Oops!
It does work this time! (probably mixed up changes).
Sorry about confusion!
As of pure iso 8601 format in SimpleDateFormatter - it is supported in Java 7:
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
So, this should do the trick: %d{yyyy-MM-dd}T%d{HH:mm:ss.SSSX}
-
20. Re: Logging filter in Jboss as 7.1.1 Final
jamezp Nov 6, 2013 7:57 PM (in response to andreypolozov)Yeah that will work. If you're running on Java 7 it should work too. The logmanager won't care what the format is, so as long as SimpleDateFormatter understands it you're good to go. So If you're running Java 7 you could just use %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}.
--
James R. Perkins