• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Log4j: Truncate from the END, conversion patterns

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to truncate priority of the logging event(DEBUG, INFO, WARN, ERROR, FATAL) from the end(not from the beginning).
I am using conversion patterns like
Sev_%.10p Application= "MyApp" Text= %m%n
But it truncate from BEGINNING & it give me last character(G, O, N, R, L). I want only first character(D, I, W, E, F)
Thanks v much,
Rakesh
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
%.-30logger NA none 30 Truncate from the end if the logger name is longer than 30 characters


dew
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to javaranch Bunty and Miguel..
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to extend pattern layout, override the createPatternParser, and create a PatternParser and a PatternConverter. Here is one I have that prints the first letter as you asked, and also prints the first 3 letters of each package level making them smaller as well.

 
reply
    Bookmark Topic Watch Topic
  • New Topic