Logger in report template

Uploaded report templates and discussions about reports.

Moderators: sarawut_w, Moderators

Logger in report template

Postby Joanny » Thu Feb 09, 2012 5:16 pm

Hello,
is it possible to add a logger in a report template to have some user specific messages in "Messages Window" of MagicDraw ?

Thank you for reply.

Joanny
Joanny
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Thu Nov 24, 2011 9:30 am

Re: Logger in report template

Postby siri_c » Thu Feb 09, 2012 10:02 pm

You may use the DialogTool to show a message dialog during report generation.
For example:

Code: Select all
#import(‘dialog’, ‘com.nomagic.reportwizard.tools.DialogTool’)
$dialog.message(“Hello World”)


The DialogTool is our built-in custom tool. You can find more information about dialog tool in "MagicDraw ReportWizard UserGuide.pdf" section 16. Dialog Tool
siri_c
Forum Expert
Forum Expert
 
Posts: 146
Posts Rating:4
Joined: Fri Jan 15, 2010 3:36 am

Re: Logger in report template

Postby siri_c » Thu Feb 09, 2012 10:07 pm

You may also develop your own custom tool to use MagicDraw API to display a message in message view.
The custom tool is described in Report Wizard UserGuide.pdf section Appendix A: Report Extensions

For example:
Code: Select all
package com.nomagic.reportwizard.tools;

import com.nomagic.magicdraw.core.Application;
import com.nomagic.magicreport.engine.Tool;

public class MessageTool extends Tool
{
   private static final long serialVersionUID = -1290565335762287159L;

   public Void message(String message)
   {
      Application.getInstance().getGUILog().log(message, true);
      return VOID;
   }
}


The code must be compiled into JAR file and place in "<install.dir>/plugins/com.nomagic.magicdraw.reportwizard/extensions" folder

A sample template code
Code: Select all
#import(‘message’, ‘com.nomagic.reportwizard.tools.MessageTool’)
$message.message(“Hello World”)


I had created a MessageTool. You can find a sample MessageTool and source code here
messagetool.jar
You do not have the required permissions to view the files attached to this post.
siri_c
Forum Expert
Forum Expert
 
Posts: 146
Posts Rating:4
Joined: Fri Jan 15, 2010 3:36 am

Re: Logger in report template

Postby Joanny » Fri Feb 10, 2012 6:25 am

Thank you for reply.

How can i logs action of report plugin in a log file when i launch the report plugin "generate" batch command ?
I tried ti modified log4j.properties in MagicDraw UML\plugins\com.nomagic.magicdraw.reportwizard directory without success.

Regards,
Joanny
Joanny
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Thu Nov 24, 2011 9:30 am

Re: Logger in report template

Postby siri_c » Sun Feb 12, 2012 11:01 pm

Log4J will look up log4j.properties from classpath. By default, when run a generate.bat in "MagicDraw UML\plugins\com.nomagic.magicdraw.reportwizard" folder, the log4j.properties will be included in classpath.

If you want to run a generate.bat in different folder, you can edit a generate.bat file and insert "-Dlog4j.configuration=path_to_log4j_properties" in this line

For example:
Code: Select all
java -Xmx800M -XX:MaxPermSize=128M -Dlog4j.configuration=file:/c:/MagicDraw UML/plugins/com.nomagic.magicdraw.reportwizard/log4j.properties  com.nomagic.magicdraw.magicreport.CommandLine %*
siri_c
Forum Expert
Forum Expert
 
Posts: 146
Posts Rating:4
Joined: Fri Jan 15, 2010 3:36 am

Re: Logger in report template

Postby Joanny » Tue Mar 13, 2012 12:40 pm

Hi,
i have modified the generate.bat for reportwizard plugin :
Code: Select all
java -Xmx800M -XX:MaxPermSize=128M -Dlog4j.configuration=file:/c:/MD/plugins/com.nomagic.magicdraw.reportwizard/log4j.properties com.nomagic.magicdraw.magicreport.CommandLine %*


the log4j.properties is :
Code: Select all
log4j.rootCategory=DEBUG,R,SO
log4j.category.REPORTS=DEBUG

log4j.appender.SO=org.apache.log4j.ConsoleAppender
log4j.appender.SO.layout=org.apache.log4j.PatternLayout
log4j.appender.SO.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.file=C:\\report.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.appender.R.maxFileSize=10000KB
log4j.appender.R.maxBackupIndex=20


When i launch the generate.bat, the report.log is created but stay empty.

When i generate my report with MagicDraw GUI, i have the following details in console :
Start Reporting...
Req V2 Plugin initializing valueManager...
sopra.magicdraw.reqv2.services.impl.DiagramManagerImpl@3d85f1
Req V2 Plugin initializing diagramManager...
sopra.magicdraw.reqv2.services.impl.DiagramManagerImpl@3d85f1
Req V2 Plugin initializing elementManager...
sopra.magicdraw.reqv2.services.impl.DiagramManagerImpl@3d85f1
Appel génération du fichier STAR-V2-SF-0019-DF02-UC003 - Refuser une demande de réquisition dématérialisée.docx


but i have no details in report.log or in standard md.log.

In which log file can i found my details ?

Thank you for reply,

Joanny
Joanny
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Thu Nov 24, 2011 9:30 am

Re: Logger in report template

Postby siri_c » Wed Mar 14, 2012 1:47 am

I have debug into a MagicDraw. I found that MagicDraw override default "log4j.configuration" property with "debug.properties.file".
You need to change a parameter to

Code: Select all
java -Xmx800M -XX:MaxPermSize=128M -Ddebug.properties.file=file:/c:/MD/plugins/com.nomagic.magicdraw.reportwizard/log4j.properties com.nomagic.magicdraw.magicreport.CommandLine %*


Sorry, for your inconvenient.
siri_c
Forum Expert
Forum Expert
 
Posts: 146
Posts Rating:4
Joined: Fri Jan 15, 2010 3:36 am

Re: Logger in report template

Postby diego.kaplan@icumed.com » Wed Dec 28, 2022 3:03 pm

Hi, I was using this in MD 19sp4 and it was very useful.
We have now migrated to MD2021x Refresh 2 HF4 and I am not able to make it work.

Are you aware of any changes I need to do so the logger will work again?
diego.kaplan@icumed.com
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Wed Sep 26, 2018 6:26 pm


Return to Report Engine

Who is online

Users browsing this forum: No registered users and 1 guest

cron