Solved

limiting logging

Posted on 2012-03-27
2
169 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

746 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

12 Experts available now in Live!

Get 1:1 Help Now