Skip to main content



      Home
Home » Archived » BIRT » How to log?
How to log? [message #90962] Tue, 15 November 2005 04:54 Go to next message
Eclipse UserFriend
Hello,

I need a function to do logging for debugging issues.

I tried scripting using:

java.lang.System.out.println("Test Log");

No error is showing but WHERE this output goes? There is no console window
available within the BIRT perspective, and if I add the console view it
keeps blank and showing 'A console is not available'

Then I tried to use the logger:

logger.logFromScript('a log message');

But I get an error message: logger is not defined.

So HOW can I use logging?!?

Thanks for any hint!
Re: How to log? [message #91116 is a reply to message #90962] Tue, 15 November 2005 12:39 Go to previous messageGo to next message
Eclipse UserFriend
Two ways to log:

1. To a log file:
The following code in the ReportDesign.initialize method creates a file on
your hard drive and adds one line to the file.

importPackage(Packages.java.io);
fos = new java.io.FileOutputStream("c:\\logFile.txt");
printWriter = new java.io.PrintWriter(fos);
printWriter.println("ReportDesign.initialize");
For every method that you want to track, provide a single statement similar
to the following statement: printWriter.println("Table.onRow: log message");
The following statement in the ReportDesign.afterFactory method closes the
file. printWriter.close();
Using this method flushes all the buffers and ensures that all method output
appears in the file. 2. Using the logger. I haven't done this in the
scripting environment, only in a Java app, so this code is entirely
theoretical. Try it, it could work!

Put this code in the ReportDesign.initialize method :

importPackage Packages.java.util.logging;
mylogger = java.util.logging.Logger.getLogger( "myLoggerName", null );

Put code similar to this in any method where you want to log information:

mylogger.log( java.util.logging.Level.INFO, "This message should appear on
the console."

--
Jane Tatchell
BIRT documentation lead

"Mr. Burns" <Mr._Burns@web.de> wrote in message
news:dlcb9l$idv$1@news.eclipse.org...
> Hello,
>
> I need a function to do logging for debugging issues.
>
> I tried scripting using:
>
> java.lang.System.out.println("Test Log");
>
> No error is showing but WHERE this output goes? There is no console window
> available within the BIRT perspective, and if I add the console view it
> keeps blank and showing 'A console is not available'
>
> Then I tried to use the logger:
>
> logger.logFromScript('a log message');
>
> But I get an error message: logger is not defined.
>
> So HOW can I use logging?!?
>
> Thanks for any hint!
>
>
Re: How to log? [message #92489 is a reply to message #91116] Fri, 18 November 2005 06:33 Go to previous message
Eclipse UserFriend
Hello Jane,

thanks for support, but does not work ;-(

I added following code:

importPackage(Packages.java.util.logging);
mylogger = java.util.logging.Logger.getLogger( "myLoggerName", null );
mylogger.log( java.util.logging.Level.INFO, "This message should appear on
the console.");

in the onCreate trigger of the chart. But I cannot see any output!
There is no error message in the log, so the code seems to be OK.

You wrote that the message should appear on the console, but in the
perspective of BIRT report there is no console,
And if I add the console view manually it gets a title: A console is not
available.

So wehre can I see the log within Eclipse BIRT perspective?

Thanks for further support!
Previous Topic:How can I change margins on the table
Next Topic:Date Format
Goto Forum:
  


Current Time: Fri Jul 18 18:37:44 EDT 2025

Powered by FUDForum. Page generated in 0.08230 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top