Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Log4j: Truncate from the END, conversion patterns

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Welcome to javaranch Bunty and Miguel..
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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.

 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!