Skip to main content



      Home
Home » Modeling » TMF (Xtext) » How to configure the Logger so that the generated ProposalProvider actually logs something?
How to configure the Logger so that the generated ProposalProvider actually logs something? [message #493025] Thu, 22 October 2009 15:02 Go to next message
Eclipse UserFriend
In the generated ProposalProvider is a Logger:

public class AbstractMyDslProposalProvider extends TerminalsProposalProvider {

private final static Logger logger = Logger.getLogger(AbstractMyDslProposalProvider.class);

public void completeModel_Imports(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (logger.isDebugEnabled()) {
logger.debug("completeModel_Imports feature '" + assignment.getFeature() + "' terminal '"
+ assignment.getTerminal() + "' cardinality '" + assignment.getCardinality() + "' and prefix '"
+ context.getPrefix() + "'");
}
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}

What do I have to do to actually make it log something?


Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: How to configure the Logger so that the generated ProposalProvider actually logs something? [message #493045 is a reply to message #493025] Thu, 22 October 2009 16:13 Go to previous messageGo to next message
Eclipse UserFriend
You have to replace the org.eclipse.xtext.logging fragment (host is
org.apache.log4j) with your own one including a custom log4j.properties.

Sven


Michael Scharf schrieb:
> In the generated ProposalProvider is a Logger:
>
> public class AbstractMyDslProposalProvider extends
> TerminalsProposalProvider {
>
> private final static Logger logger =
> Logger.getLogger(AbstractMyDslProposalProvider.class);
>
> public void completeModel_Imports(EObject model, Assignment
> assignment, ContentAssistContext context, ICompletionProposalAcceptor
> acceptor) {
> if (logger.isDebugEnabled()) {
> logger.debug("completeModel_Imports feature '" +
> assignment.getFeature() + "' terminal '"
> + assignment.getTerminal() + "' cardinality '" +
> assignment.getCardinality() + "' and prefix '"
> + context.getPrefix() + "'");
> }
> completeRuleCall(((RuleCall)assignment.getTerminal()), context,
> acceptor);
> }
>
> What do I have to do to actually make it log something?
>
>
> Michael


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: How to configure the Logger so that the generated ProposalProvider actually logs something? [message #493070 is a reply to message #493045] Thu, 22 October 2009 19:54 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sven,

> You have to replace the org.eclipse.xtext.logging fragment (host is
> org.apache.log4j) with your own one including a custom log4j.properties.

Is there somewhere an example of that? (I am not familiar with log4j and
might take me some time to figure that out without an example)

Michael

> Sven
>
>
> Michael Scharf schrieb:
>> In the generated ProposalProvider is a Logger:
>>
>> public class AbstractMyDslProposalProvider extends
>> TerminalsProposalProvider {
>> private final static Logger logger =
>> Logger.getLogger(AbstractMyDslProposalProvider.class);
>> public void completeModel_Imports(EObject model, Assignment
>> assignment, ContentAssistContext context, ICompletionProposalAcceptor
>> acceptor) {
>> if (logger.isDebugEnabled()) {
>> logger.debug("completeModel_Imports feature '" +
>> assignment.getFeature() + "' terminal '"
>> + assignment.getTerminal() + "' cardinality '" +
>> assignment.getCardinality() + "' and prefix '"
>> + context.getPrefix() + "'");
>> }
>> completeRuleCall(((RuleCall)assignment.getTerminal()),
>> context, acceptor);
>> }
>>
>> What do I have to do to actually make it log something?
>>
>>
>> Michael
>
>


--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: How to configure the Logger so that the generated ProposalProvider actually logs something? [message #493098 is a reply to message #493070] Fri, 23 October 2009 03:10 Go to previous messageGo to next message
Eclipse UserFriend
Michael Scharf schrieb:
> Hi Sven,
>
>> You have to replace the org.eclipse.xtext.logging fragment (host is
>> org.apache.log4j) with your own one including a custom log4j.properties.
>
> Is there somewhere an example of that? (I am not familiar with log4j and
> might take me some time to figure that out without an example)

The easiest way is to check out the org.eclipse.xtext.logging fragment
from CVS and in the log4j.properties change WARN to DEBUG for the
packages you want to lower the debug level.

There's of course some documentation (incl. examples) on the log4j website.

Cheers,
Sven

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: How to configure the Logger so that the generated ProposalProvider actually logs something? [message #493121 is a reply to message #493098] Fri, 23 October 2009 05:38 Go to previous message
Eclipse UserFriend
Hello Michael,


to change log4j configuration out of Workflow file I wrote this bean:
package net.sf.securejdms.wme;

import org.apache.log4j.xml.DOMConfigurator;

public class Log4JConfigurator {
	public void setXml(String xml) {
		DOMConfigurator.configure(this.getClass().getResource(xml));
	}
}


You have to add a bean declaration into your workflow MWE file :
<workflow>
...
<bean class="net.sf.securejdms.wme.Log4JConfigurator" xml="/workflow/log4j.xml" />
...
</workflow>


My log4j.xml file (layout matches MWE default layout):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration>
	<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%-5r[%t] %-5p %-35.35C  - %m%n" />
		</layout>
	</appender>
	<root>
		<level value="INFO" />
		<appender-ref ref="stdout"/>
	</root>
</log4j:configuration>


Here you can change INFO to DEBUG or TRACE to see more output.


Regards,
Boris Brodski
Previous Topic:How to force an object to be created if no attribute is assigned?
Next Topic:How to get element of another model which is NOT referenced?
Goto Forum:
  


Current Time: Sat Jul 19 22:39:27 EDT 2025

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

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

Back to the top