user
user

Reputation: 914

BIRT Console is not displaying anything

I am attempting to display to my console using BIRT, however I am having no success. I am using eclipsec.exe, and trying to display a simple count on console.

for(var i=1; i<11; i++) 
{ 
    Packages.java.lang.System.out.println ("Count is: " + i); 
} 

However the console does not display anything.

Upvotes: 0

Views: 1420

Answers (2)

Ksenia
Ksenia

Reputation: 3753

It seems that it's impossible to output log in Eclipse console, but this is, in my opinion, the easiest workaround - to log into a file:

importPackage(Packages.java.io);
out = new PrintWriter(new FileWriter("d:/LOG.txt", true));
out.println("Test Event");
out.close();

You just have to put these 4 line in your script and you'll get logs in the file.

Upvotes: 1

hvb
hvb

Reputation: 2669

I know this is not a direct answer, but as an alternative, you could use java.util.logging like this:

When starting eclipse, add the argument -vmargs -Djava.util.logging.config.file=\path\to\logging.properties

The logging.properties file could look like this:

handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = /path/to/birt-designer.log
java.util.logging.FileHandler.limit = 5000000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = ALL

Then in the initialize script of the report, add something like this:

importPackage(Packages.java.util.logging);
var log = {
    _log: Logger.getLogger("birt.js"),
    debug: function(s) { this._log.fine(s); },
    info: function(s) { this._log.info(s); },
    warn: function(s) { this._log.warning(s); },
    warning: function(s) { this._log.warning(s); },
    error: function(args) {
        this._log.severe("" + args);
    }
};
log._log.setLevel(Level.ALL);

Now you can log like this:

log.debug("Whatever");
log.info("Blah Blah");
log.warn("Something looks insane");
log.error("Something went completely wrong");

Upvotes: 1

Related Questions