Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » how to create log to debug
how to create log to debug [message #666959] Mon, 25 April 2011 06:05 Go to next message
tong123123 tong123123 is currently offline tong123123 tong123123
Messages: 74
Registered: April 2011
Member
I want to create a log file named birt.log and all log information will be placed in this file. but I found the output log file is named birt.log1, birt.log1.lck, birt.log.2, birt.log2.lck, each time I run "view report in web viewer" in eclipse, a new log file is created with a new suffix (.1, .2., .3, ...., .n), why this would happen?

the code to create log is as follow:
in initialize event:
importPackage(Packages.java.util.logging);
logger = Logger.getLogger("");
logger.setLevel(Level.INFO);
fileHandler = new FileHandler("c:/birt.log", 100000, 1, true);
fileHandler.setFormatter(new XMLFormatter());
//var rootLogger = Logger.getLogger("");
//rootLogger.addHandler(fileHandler);
logger.addHandler(fileHandler);
logger.info("--initialize''");


in dataset beforeopen event
if (params["NewParameter4"].value == "uptime"){
	this.queryText = this.queryText.replaceAll(":salary", params["good"]);
}else{
	this.queryText = this.queryText.replaceAll(":salary", params["bad"]);
}

fileHandler.setFormatter(new XMLFormatter());

//var rootLogger = Logger.getLogger("");
//rootLogger.addHandler(fileHandler);
logger.addHandler(fileHandler);
logger.log(Level.INFO, this.queryText);
logger.logp(Level.INFO, "contract_current_salary", "beforeOpen", "Logging an INFO-level message");
this.queryText = this.queryText.replaceAll(">=", "xxx ");
logger.info(this.queryText);
Packages.java.lang.System.out.println ("this.queryText: " + this.queryText);


I want to attached the xml file, but where is the upload button?
Re: how to create log to debug [message #667080 is a reply to message #666959] Mon, 25 April 2011 15:04 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I assume this is because you the viewer does not shutdown once you start
it in the designer and the initialize event is called many times. So
your code continues to add handlers. Try moving the code to the
beforeFactory and using code like this:

importPackage(Packages.java.util.logging);
logger = Logger.getLogger("mybirttest");
myhandlers = logger.getHandlers();
if( myhandlers.length == 0 ){
logger.setLevel(Level.INFO);
fileHandler = new FileHandler("c:/test/birt.log", 100000, 1, true);
fileHandler.setFormatter(new XMLFormatter());
//var rootLogger = Logger.getLogger("");
//rootLogger.addHandler(fileHandler);
logger.addHandler(fileHandler);
}
logger.info("--initialize''");

Jason
On 4/25/2011 2:05 AM, tong123123@yahoo.com.hk wrote:
> fileHandler.setFormatter(new XMLFormatter());
>
> //var rootLogger = Logger.getLogger("");
> //rootLogger.addHandler(fileHandler);
> logger.addHandler(fileHandler);
> logger.log(Level.INFO, this.queryText);
> logger.logp(Level.INFO, "contract_current_salary", "beforeOpen",
> "Logging an INFO-level message");
> this.queryText = this.queryText.replaceAll(">=", "xxx ");
> logger.info(this.queryText);
> Packages.java.lang.System.out.println ("this.queryText: " +
> this.queryText);
Re: how to create log to debug [message #668218 is a reply to message #666959] Wed, 04 May 2011 14:41 Go to previous messageGo to next message
tong123123 tong123123 is currently offline tong123123 tong123123
Messages: 74
Registered: April 2011
Member
I try to move the code to beforeFactory but the same problem occur, each time I run the "vew as web viewer", a .log.n and a .log.n.lck file is produced (n = 1,2,3,...,n). I ensure after each run, I already close the web viewer.
the code in beforeFactory is
logger = Logger.getLogger("mybirttest");
myhandlers = logger.getHandlers();
Packages.java.lang.System.out.println ("myhandlers.length = " + myhandlers.length);
if( myhandlers.length == 0 ){
	logger.setLevel(Level.INFO);
	fileHandler = new FileHandler("c:/birt.log", 100000, 1, true);
	fileHandler.setFormatter(new XMLFormatter());	
	logger.addHandler(fileHandler);
}
logger.info("--initialize''");

also, I have a dataset and in its beforeOpen event, I add the following script

if (params["NewParameter4"].value == "uptime"){
	this.queryText = this.queryText.replaceAll(":salary", params["good"]);
}else{
	this.queryText = this.queryText.replaceAll(":salary", params["bad"]);
}
//this.queryText = this.queryText.replaceAll(">=", "xxx ");
Packages.java.lang.System.out.println ("this.queryText: " + this.queryText);


when I run the program two time (close the web viewer and run again), and check the message in eclipsec.exe prompt, the following is output:
myhandlers.length = 0
2011/5/4 下午 10:34:00 sun.reflect.NativeMethodAccessorImpl invoke0
資訊: --initialize''
this.queryText: select *
from contract_current_salary
where current_salary >= '20000'
order by current_salary;
myhandlers.length = 0
2011/5/4 下午 10:34:58 sun.reflect.NativeMethodAccessorImpl invoke0
資訊: --initialize''
this.queryText: select *
from contract_current_salary
where current_salary >= '20000'
order by current_salary;

Re: how to create log to debug [message #668241 is a reply to message #668218] Wed, 04 May 2011 15:24 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

What version of BIRT are you using? I did this in 2.6.1 and I only get
one log file. Take a look at the attached report.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.6.1.v20100902 Build &lt;2.6.1.v20100915-1750></property>
<property name="units">in</property>
<method
name="beforeFactory"><![CDATA[importPackage(Packages.java.util.logging);
logger = Logger.getLogger("mybirttest");
myhandlers = logger.getHandlers();
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/test/logevents.txt", true ) );
out.println( "tst" + myhandlers.length);
out.close();

if( myhandlers.length == 0 ){
logger.setLevel(Level.INFO);
fileHandler = new FileHandler("c:/test/birt.log", 100000, 1, true);
fileHandler.setFormatter(new XMLFormatter());
//var rootLogger = Logger.getLogger("");
//rootLogger.addHandler(fileHandler);
logger.addHandler(fileHandler);
}
logger.info("--initialize''");]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<oda-data-source
extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source"
id="7">
<list-property name="privateDriverProperties">
<ex-property>
<name>contentBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>metadataBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
</list-property>
<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="Data Set" id="8">
<list-property name="columnHints">
<structure>
<property name="columnName">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
<text-property
name="heading">ORDERNUMBER</text-property>
</structure>
<structure>
<property name="columnName">PRODUCTCODE</property>
<text-property
name="displayName">PRODUCTCODE</text-property>
<text-property
name="heading">PRODUCTCODE</text-property>
</structure>
<structure>
<property name="columnName">QUANTITYORDERED</property>
<text-property
name="displayName">QUANTITYORDERED</text-property>
<text-property
name="heading">QUANTITYORDERED</text-property>
</structure>
<structure>
<property name="columnName">PRICEEACH</property>
<text-property
name="displayName">PRICEEACH</text-property>
<text-property name="heading">PRICEEACH</text-property>
</structure>
<structure>
<property name="columnName">ORDERLINENUMBER</property>
<text-property
name="displayName">ORDERLINENUMBER</text-property>
<text-property
name="heading">ORDERLINENUMBER</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="dataType">float</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<method name="beforeOpen"><![CDATA[

logger.log(Level.INFO, this.queryText);
logger.log(Level.INFO, "beforeOpen Logging an INFO-level message");


]]></method>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="nativeName">ORDERNUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="nativeName">PRODUCTCODE</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="nativeName">QUANTITYORDERED</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="nativeName">PRICEEACH</property>
<property name="dataType">float</property>
<property name="nativeDataType">8</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="nativeName">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">5</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select *
from orderdetails
where ordernumber = 10101]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERNUMBER</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERNUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERNUMBER</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRODUCTCODE</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRODUCTCODE</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRODUCTCODE</design:label>
<design:formattingHints>
<design:displaySize>15</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>QUANTITYORDERED</design:name>
<design:position>3</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>QUANTITYORDERED</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>QUANTITYORDERED</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRICEEACH</design:name>
<design:position>4</design:position>
<design:nativeDataTypeCode>8</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRICEEACH</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRICEEACH</design:label>
<design:formattingHints>
<design:displaySize>22</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERLINENUMBER</design:name>
<design:position>5</design:position>
<design:nativeDataTypeCode>5</design:nativeDataTypeCode>
<design:precision>5</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERLINENUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERLINENUMBER</design:label>
<design:formattingHints>
<design:displaySize>6</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="9">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
<expression name="expression"
type="javascript">dataSetRow["ORDERNUMBER"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">PRODUCTCODE</property>
<text-property
name="displayName">PRODUCTCODE</text-property>
<expression name="expression"
type="javascript">dataSetRow["PRODUCTCODE"]</expression >
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">QUANTITYORDERED</property>
<text-property
name="displayName">QUANTITYORDERED</text-property>
<expression name="expression"
type="javascript">dataSetRow["QUANTITYORDERED"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">PRICEEACH</property>
<text-property
name="displayName">PRICEEACH</text-property>
<expression name="expression"
type="javascript">dataSetRow["PRICEEACH"]</expression>
<property name="dataType">float</property>
</structure>
<structure>
<property name="name">ORDERLINENUMBER</property>
<text-property
name="displayName">ORDERLINENUMBER</text-property>
<expression name="expression"
type="javascript">dataSetRow["ORDERLINENUMBER"]</expression >
<property name="dataType">integer</property>
</structure>
</list-property>
<column id="38"/>
<column id="39"/>
<column id="40"/>
<column id="41"/>
<column id="42"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property
name="text">ORDERNUMBER</text-property>
</label>
</cell>
<cell id="13">
<label id="14">
<text-property
name="text">PRODUCTCODE</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property
name="text">QUANTITYORDERED</text-property>
</label>
</cell>
<cell id="17">
<label id="18">
<text-property
name="text">PRICEEACH</text-property>
</label>
</cell>
<cell id="19">
<label id="20">
<text-property
name="text">ORDERLINENUMBER</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="21">
<cell id="22">
<data id="23">
<property name="whiteSpace">nowrap</property>
<property
name="resultSetColumn">ORDERNUMBER</property>
</data>
</cell>
<cell id="24">
<data id="25">
<property name="whiteSpace">nowrap</property>
<property
name="resultSetColumn">PRODUCTCODE</property>
</data>
</cell>
<cell id="26">
<data id="27">
<property name="whiteSpace">nowrap</property>
<property
name="resultSetColumn">QUANTITYORDERED</property>
</data>
</cell>
<cell id="28">
<data id="29">
<property name="whiteSpace">nowrap</property>
<property
name="resultSetColumn">PRICEEACH</property>
</data>
</cell>
<cell id="30">
<data id="31">
<property name="whiteSpace">nowrap</property>
<property
name="resultSetColumn">ORDERLINENUMBER</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="32">
<cell id="33"/>
<cell id="34"/>
<cell id="35"/>
<cell id="36"/>
<cell id="37"/>
</row>
</footer>
</table>
</body>
</report>


On 5/4/2011 10:41 AM, tong123123@yahoo.com.hk wrote:
> I try to move the code to beforeFactory but the same problem occur, each
> time I run the "vew as web viewer", a .log.n and a .log.n.lck file is
> produced (n = 1,2,3,...,n). I ensure after each run, I already close the
> web viewer.
> the code in beforeFactory is
>
> logger = Logger.getLogger("mybirttest");
> myhandlers = logger.getHandlers();
> Packages.java.lang.System.out.println ("myhandlers.length = " +
> myhandlers.length);
> if( myhandlers.length == 0 ){
> logger.setLevel(Level.INFO);
> fileHandler = new FileHandler("c:/birt.log", 100000, 1, true);
> fileHandler.setFormatter(new XMLFormatter());
> logger.addHandler(fileHandler);
> }
> logger.info("--initialize''");
>
> also, I have a dataset and in its beforeOpen event, I add the following
> script
>
>
> if (params["NewParameter4"].value == "uptime"){
> this.queryText = this.queryText.replaceAll(":salary", params["good"]);
> }else{
> this.queryText = this.queryText.replaceAll(":salary", params["bad"]);
> }
> //this.queryText = this.queryText.replaceAll(">=", "xxx ");
> Packages.java.lang.System.out.println ("this.queryText: " +
> this.queryText);
>
>
> when I run the program two time (close the web viewer and run again),
> and check the message in eclipsec.exe prompt, the following is output:
>
> myhandlers.length = 0
> 2011/5/4 下午 10:34:00 sun.reflect.NativeMethodAccessorImpl invoke0
> 資訊: --initialize''
> this.queryText: select *
> from contract_current_salary
> where current_salary >= '20000'
> order by current_salary;
> myhandlers.length = 0
> 2011/5/4 下午 10:34:58 sun.reflect.NativeMethodAccessorImpl invoke0
> 資訊: --initialize''
> this.queryText: select *
> from contract_current_salary
> where current_salary >= '20000'
> order by current_salary;
>
>
Re: how to create log to debug [message #668249 is a reply to message #666959] Wed, 04 May 2011 16:17 Go to previous messageGo to next message
tong123123 tong123123 is currently offline tong123123 tong123123
Messages: 74
Registered: April 2011
Member
I use birt designer 2.2.1
Quote:

<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.15" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.2.1.r221_v20070924 Build &lt;2.2.0.v20070924-1550></property>



could you provide a sample for 2.2.1?
thanks in advance
Re: how to create log to debug [message #668263 is a reply to message #668249] Wed, 04 May 2011 18:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I could not get this to work in birt 2.2.1.

Jason

On 5/4/2011 12:17 PM, tong123123@yahoo.com.hk wrote:
> I use birt designer 2.2.1
> Quote:
>> <report xmlns="http://www.eclipse.org/birt/2005/design"
>> version="3.2.15" id="1">
>> <property name="createdBy">Eclipse BIRT Designer Version
>> 2.2.1.r221_v20070924 Build <2.2.0.v20070924-1550></property>
>
>
> could you provide a sample for 2.2.1?
> thanks in advance
Re: how to create log to debug [message #668302 is a reply to message #666959] Thu, 05 May 2011 02:12 Go to previous messageGo to next message
tong123123 tong123123 is currently offline tong123123 tong123123
Messages: 74
Registered: April 2011
Member
oh, you means your sample file cannot work in birt designer 2.2.1? but if the logging method
importPackage(Packages.java.util.logging);
logger = Logger.getLogger("mybirttest");
myhandlers = logger.getHandlers();

possible in birt designer 2.2.1?
Re: how to create log to debug [message #668416 is a reply to message #668302] Thu, 05 May 2011 15:10 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

What I meant is that depending on how you preview in 2.2.1 I can not get
it to send everything to one log file like I can with 2.6.1.

Jason

On 5/4/2011 10:12 PM, tong123123@yahoo.com.hk wrote:
> oh, you means your sample file cannot work in birt designer 2.2.1? but
> if the logging method
>
> importPackage(Packages.java.util.logging);
> logger = Logger.getLogger("mybirttest");
> myhandlers = logger.getHandlers();
>
> possible in birt designer 2.2.1?
Previous Topic:export birt report rcp designer
Next Topic:Question about mysql connector installation and configuration:
Goto Forum:
  


Current Time: Tue Sep 16 09:27:59 GMT 2014

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

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