Solved

limiting logging

Posted on 2012-03-27
2
174 Views
Last Modified: 2012-03-29
I am logging a long string to standard out for debugging using system.out.println.
How can I limit it to just the first 80 characters or so?
0
Comment
Question by:dpalyca755
2 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 250 total points
ID: 37773795
can you say, for wexample, if your string is myString:

log.debug(myString.substring(0, Math.min(myString.length()-1,80)));
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 250 total points
ID: 37774339
using system.out.println

You should use a proper logging framework. Logback is the best. It will give you complete control over the length of your logged strings. Although there is quite a bit of code on this page, it's for illustrative purposes - you don't need to write any

http://logback.qos.ch/manual/layouts.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
best (free) software to access postgres db (java) 1 33
rhino JavaScript import, load 25 69
replace a word with other 1 40
fibonacci ten numbers 4 30
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now