Skip to Content

Handle Standard JAVA Output Using Log File

Standard JAVA Output

In JAVA programming, standard output(System.out) is frequently used for
tracing and debugging purpose.  The standard JAVA output prints the
information to the console, but in some particular scenes, we may hope it will
print the information to a certain file.

Also, a lots of beginners will wonder how to get the output information of the
standard JAVA output in server-side JAVA application such as EJB. That’s why
this weblog comes out.

Standard Output in Plain JAVA

In plain JAVA code, you can reassign the standard output stream to a file.

File file = new File(“c:
PrintStream printStream = new PrintStream(file);
System.out.println(“Hello World!”);

The string “Hello World!” will be in the file c:\PrintConsole.txt.

Standard Output in EJB

For certain reasons, usage of System.setOut method in EJBs deployed onto the
SAP J2EE Engine will cause exceptions. Thus, we can only use other ways to get
standard output information. One is reassign the standard output to the default
trace file, the other is reassign the standard output to a specified file.

P.S: During configuring of JAVA Visual Administrator of WAS 6.40, I strongly recommend
you to put the console window which you start the VA right beside the VA
windows. The Log Configurator and Log Viewer service of VA is not implemented so
good that JAVA Exceptions will be frequently threw out. When you found this in
console window, quit the VA, restart it, and then continue the progress from the
step the exception was threw.

Caution: You would only turn on tracing of Standard JAVA Output if
your java code has some problems and you want to get the running status of the
code, after that, you should turn off the tracing of Standard JAVA Output.

I. Reassign Standard JAVA Output to the Default Trace File

    1. Operations in Log Configurator


  • Open Visual Administrator.
  • Click the “Log Configurator” node under Cluster->Server->Services.
  • Select the “Locations” tab.
  • In the “Log Controllers” pane, select the “out” node under Root
  • In the right pane, choose the “Info” for severity.
  • Save the change by clicking the save button.

    1. Operations in Log Viewer


II. Reassign Standard JAVA Output to A Specified File

    1. Operations in ConfigTool


  1. Open the ConfigTool.

Switch to configuration editor mode by clicking the

    1. Navigate to cluster_data->server->cfg->kernel.

Switch to edit mode by clicking the

    1. Double click on the “Propertysheet LogManager” node to change the
      Log properties.
    2. Change the property “ForceSingleTraceFile” from default “YES” to
      “NO”, and click “Apply custom” button.
    1. Operations in Log Configurator


  1. Open Visual Administrator.
  2. Click the “Log Configurator” node under Cluster->Server->Services.
  3. Switch to advanced mode by clicking the “To advanced mode” button.
  4. Create a destionation.
      1. Choose Destinations Tab.
      2. Ceate a new destination by clicking “New” button in the
        right pane, a popup dialog will appear.
      3. Fill the “Name:” field for destination name, such as “TestLogDestination”.
      4. Choose the “FileLog” as the “Type”.
      5. Fill the “File Name Pattern:” for log file path and file
        name, such as “/tmp/log.txt”.
      6. Fill the “Maximum File Size:” for log file size, such as “1048576”.
      7. Fill the “Number Of Files:” for number of log files, such as
        “2”, then you’ll find log.0.txt and log.1.txt under path /tmp.
      8. After all fields have been filled, click button “OK”.
      9. Fill the “Encoding:” for log file encoding, such as “UTF-8”.
      10. Add a formatter.
          1. Click the “Add” button beside the Formatter pane,
            the Add Formatter popup dialog will appear.
          2. Click the “Anonymous” button, choose “List
            Formatter” in the popup dialog and click “OK” button.
          3. The “Anonymous[ListFormatter] item will be in the
            list, choose it and click “Select” button.

Save by click image button.


      1. Add the new created destination to Locations.
      1. Choose “Locations” Tab and click the “Add” button beside the “Destinations” pane, a popup dialog will appear.
      2. Select the destination that we’ve just created and click “Select” button.

    Save by click image button.

    Now we’ve finished everything we should do in Log Configurator.



      1. Operations in LogViewer


    1. Click the “LogViewer” node under Cluster->Server->Services.
    2. In the area below runtime tab, right click “Cluster” node and choose
      “Add a log file”, “Add monitorable file” popup dialog will appear.

    In the “Enter a file:” field, enter the path and file name of your
              destination log file. We enter “\tmp\log.” for example.

    Wildcard characters can be use here. “*” stands for any string and “…”
    stands for cross multiple directories.

    The path of your log file must be “monitorable”, that means, the path
    should be added to “Logviewer_MonitorablePath” property under
    “Properties” tab of “LogViewer” service. The monitorable paths should be
    seperated using ‘;’.

      1. Click the “Show File List” button and the log files would appear in
        the right pane. Choose it and click “Add” button below.


    You must be Logged on to comment or reply to a post.
    • Hi, <br/><br/>When I follow your tutorial I get this (Apparantly the server changed the name from .\log\eee.0.log to .\log\eee.log.0)<br/>Is this a bug in NW?)<br/><br/><!LOGHEADER[START]/><br/><!HELP[Manual modification of the header may cause parsing problem!]/><br/><!LOGGINGVERSION[ – 630]/><br/><!NAME[.\log\eee.log]/><br/><!PATTERN[eee.log]/><br/><!FORMATTER[]/><br/><!ENCODING[Cp1252]/><br/><!FILESET[0, 3, 100000]/><br/><!PREVIOUSFILE[eee.2.log]/><br/><!NEXTFILE[eee.1.log]/><br/><!LOGHEADER[END]/><br/>[impl:3]_2##0#0#Path#1#/System/Logging#Java#7D4E986F-B684-4942-B3E7-FEDA3AB57100##Error in opening File(.
      eee.log.0)!##<br/>[impl:3]_2##0#0#Path##Java###Error in opening File(.
      eee.log.0)! <br/>[EXCEPTION]<br/> Error in opening File(.
      eee.log.0)!     at

      • I haven’t seen this kind of exception before.
        Tell me more details, how do you maintain the “Pattern:” filed in destination?
        Are there \log\eee.0.log, \log\eee.1.log in your operation system?
        Can you monitor eee.log in the logViewer?
        Is the \log\ path one of the monitorable paths?