Beanshell Log File

Posted on 2007-07-25
Last Modified: 2012-05-05
I want to trace execution in a beanshell script, writing text and variables to a text file.  

 - How do I create a text file, in beanshell?  
 - How do I append text to a text file, in a beanshell script?
Question by:LarryAndro
    LVL 86

    Accepted Solution

    Just as you would in a Java app

    PrintWriter out = new PrintWriter(new FIleWriter("x.txt"));
    LVL 1

    Author Comment

    I'm making things too hard!  Thanks...

    (If anyone reads, and copies and pastes the code above, change FIleWriter... to FileWriter...)
    LVL 86

    Expert Comment


    Using a logging API such as log4j would be better, but i'm not fully sure if it can be used in exactly the same way in beanshell

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    tenRun challenge 28 72
    Core java. Please help me catch a bug. 5 52
    nestparen challenge 4 37
    firstChar challenge 13 60
    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    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…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now