• 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

Problem in alignning the text in java?

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am using log4j to log the user details when a submit is clicked in form page. Name, Email address, company etc all details of the user. However after writing to log file, when I open the log file in notepad, the alignment is not good, but if i open the log file in wordpad, the alignment is good.

Sample code:

String htmlContent = "\t" + serverProperties.getString("mail.subject")+" "+ mailFrom + " \n"+
"-----------------------------------------------------------------------------------------" + "\n" +
"\t" + "Type " + "\t" + "|" + "\t" + "Product Info " + "\t" + "-" + "\t" + rq_type_info + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Product Demo " + "\t" + "-" + "\t" + rq_type_demo + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Product Evaluation" + "\t" + "-" + "\t" + rq_type_eval + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Services Info " + "\t" + "-" + "\t" + rq_type_services + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Newsletter " + "\t" + "-" + "\t" + rq_type_news + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Contact Sales " + "\t" + "-" + "\t" + rq_type_sales + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Login Access " + "\t" + "-" + "\t" + rq_type_login + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Others " + "\t" + "-" + "\t" + rq_type_others + "\n" +
"\t" + "Name " + "\t" + "|" + "\t" + name + "\n" +
"\t" + "Company " + "\t" + "|" + "\t" + company +"\n" +
"\t" + "Job Title " + "\t" + "|" + "\t" + jobTitle + "\n" +
"\t" + "Division " + "\t" + "|" + "\t" + division +"\n" +
"\t" + "Email Id " + "\t" + "|" + "\t" + mailFrom + "\n" +
"\t" + "Work Phone " + "\t" + "|" + "\t" + workPhone + "\n" +
"\t" + "Country " + "\t" + "|" + "\t" + country +"\n" +
"\t" + "Areas of Interest " + "\t" + "|" + "\t" + productGroup +"\n" +
"\t" + "Additional Information" + "\t \t" + "|" + "\t" + additionalInfo +" \n"+
"-----------------------------------------------------------------------------------------";

I have done so, using '\t' tab space but this is not common in notepad and in wordpad.

Please let me share your ideas to do it in java, so that the alignment looks good in notepad and in wordpad.

REgards,
Prabhu.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't log4j supply log formatting mechanisms that mean you don't have to add all these white space characters to your log message?

Indeed it does. Have a read of the documentation about PatternLayouts.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alignment of plain text in text editors depends on the font you're using, tab size, etc.

Why are you calling a variable "htmlContent" when there's no HTML in it? Is this supposed to actually be an email? An HTML email?
reply
    Bookmark Topic Watch Topic
  • New Topic