Fornax-Platform
Forum

logging with fornax-oaw-m2-plugin

View: New views
12 Messages — Rating Filter:   Alert me  

logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I tried updating fornax-oaw-m2-plugin from version 2.1.1 to 3.0.1.  It looks like logging has changed.  I now gets *tons* of debug output that I never used to see, like:

[org.openarchitectureware.xpand2.output.FileHandleImpl] : Opening file : C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
[org.openarchitectureware.xpand2.output.FileHandleImpl] : Skipping file : C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html cause it exists already

How do I change the log level?  I have a log4j.xml file under src/test/resources that I use with SureFire, but this does not affect the oAW output.

Please advise.

Thanks!
--Polly

Re: logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I turned on "-Dlog4j.debug".  It looks like in fornax-oaw-m2-plugin 2.1.1, log4j finds the log4j.properties file from oAW that limits the amount of logging:

[INFO] [fornax-oaw-m2:run-workflow {execution: generate-main}]
[INFO] oAW Maven2 Plugin V2.1.1
log4j: Trying to find [log4j.xml] using context classloader org.codehaus.classworlds.RealmClassLoader@1bbdd48.
log4j: Trying to find [log4j.xml] using org.codehaus.classworlds.RealmClassLoader@1bbdd48 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader org.codehaus.classworlds.RealmClassLoader@1bbdd48.
log4j: Using URL [jar:file:/C:/Documents and Settings/pchang/.m2/repository/org/openarchitectureware/oaw-core-workflow/4.3.1/oaw-core-workflow-4.3.1.jar!/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL jar:file:/C:/Documents and Settings/pchang/.m2/repository/org/openarchitectureware/oaw-core-workflow/4.3.1/oaw-core-workflow-4.3.1.jar!/log4j.properties
log4j: Parsing for [root] with value=[INFO, A1 ].
log4j: Level token is [INFO].
log4j: Category root set to INFO
log4j: Parsing appender named "A1".
log4j: Parsing layout options for "A1".
log4j: Setting property [conversionPattern] to [%-4r %-5p %-18C{1} - %m%n].
log4j: End of parsing for "A1".
log4j: Parsed "A1" options.
log4j: Parsing for [de.hunsicker] with value=[ERROR].
log4j: Level token is [ERROR].
log4j: Category de.hunsicker set to ERROR
log4j: Handling log4j.additivity.de.hunsicker=[null]
log4j: Finished configuring.
0    INFO  WorkflowRunner     - --------------------------------------------------------------------------------------
0    INFO  WorkflowRunner     - openArchitectureWare v4.3.1
0    INFO  WorkflowRunner     - (c) 2005-2008 openarchitectureware.org and contributors
0    INFO  WorkflowRunner     - --------------------------------------------------------------------------------------
0    INFO  WorkflowRunner     - running workflow: workflow.oaw
0    INFO  WorkflowRunner     -

After switching to fornax-oaw-m2-plugin 3.0.1, log4j is no longer looking for the file:

[INFO] [fornax-oaw-m2:run-workflow {execution: generate-main}]
[INFO] Fornax oAW/MWE Maven2 Plugin V3.0.1
[org.openarchitectureware.workflow.WorkflowRunner] : --------------------------------------------------------------------------------------
[org.openarchitectureware.workflow.WorkflowRunner] : openArchitectureWare v4.3.1
[org.openarchitectureware.workflow.WorkflowRunner] : (c) 2005-2008 openarchitectureware.org and contributors
[org.openarchitectureware.workflow.WorkflowRunner] : --------------------------------------------------------------------------------------
[org.openarchitectureware.workflow.WorkflowRunner] : running workflow: workflow.oaw
[org.openarchitectureware.workflow.WorkflowRunner] :

What changed in the plugin in 3.0.1?  Can you change it back?

Thanks,
--Polly


On Tue, Jun 23, 2009 at 5:44 PM, polly.c.chang <polly.c.chang@...> wrote:

Hi,

I tried updating fornax-oaw-m2-plugin from version 2.1.1 to 3.0.1.  It looks
like logging has changed.  I now gets *tons* of debug output that I never
used to see, like:

[org.openarchitectureware.xpand2.output.FileHandleImpl] : Opening file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
[org.openarchitectureware.xpand2.output.FileHandleImpl] : Skipping file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
cause it exists already

How do I change the log level?  I have a log4j.xml file under
src/test/resources that I use with SureFire, but this does not affect the
oAW output.

Please advise.

Thanks!
--Polly
--
View this message in context: http://www.nabble.com/logging-with-fornax-oaw-m2-plugin-tp24175022s17564p24175022.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by Karsten Thoms-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Polly,

logging has been changed to Commons Logging. I will change this back next week, maybe I can already deploy a snapshot tomorrow.
Opened Bug: https://fornax.itemis.de/jira/browse/TOM-26

~Karsten


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Thursday, June 25, 2009 3:09:08 AM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks!

--Polly


On Thu, Jun 25, 2009 at 2:21 AM, Karsten Thoms <thoms@...> wrote:
Hi Polly,

logging has been changed to Commons Logging. I will change this back next week, maybe I can already deploy a snapshot tomorrow.
Opened Bug: https://fornax.itemis.de/jira/browse/TOM-26

~Karsten


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Thursday, June 25, 2009 3:09:08 AM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by Karsten Thoms :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Polly, 

when looking at the sources I recognized that it might be no issue of the Fornax Maven plugin. Debug output has changed there, but just regarding the debug output that the plugin does. This is now I mean correctly directed to the Plugin's context logger, and these debug messages are activated when running mvn -X install.
I saw that Sculptor overrides the log4j configuration for Surefire in their library example project like this:

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3</version>
<configuration>
<skip>false</skip>
<forkMode>pertest</forkMode>
<!-- <forkMode>once</forkMode> -->
<argLine>-Xms32m -Xmx1024m -Dlog4j.configuration=log4j-test.properties</argLine>
<excludes>
<exclude>**/IsolatedDatabaseTestCase.java</exclude>
</excludes>
</configuration>
</plugin>

Could you check if this would work for you, too?

Best wishes,
~Karsten

Am 25.06.2009 um 16:43 schrieb Polly C. Chang:

Thanks!

--Polly


On Thu, Jun 25, 2009 at 2:21 AM, Karsten Thoms <thoms@...> wrote:
Hi Polly,

logging has been changed to Commons Logging. I will change this back next week, maybe I can already deploy a snapshot tomorrow.
Opened Bug: https://fornax.itemis.de/jira/browse/TOM-26

~Karsten


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Thursday, June 25, 2009 3:09:08 AM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Karsten,

I have the same setup for the Surefire plugin, and that works fine.  The problems is that before we get to the unit tests, when Maven is generating sources, there is tons of debug output from oAW and Hybridlabs Beautifier.  I put a log4j.xml file in src/main/resources and that still doesn't turn off the oAW messages (though I am able to turn off the Hybridlabs messages). 

Are you able to turn off all the "Opening file", "Skipping file" kind of debug messages?

[org.openarchitectureware.
xpand2.output.FileHandleImpl] : Opening file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
[org.openarchitectureware.xpand2.output.FileHandleImpl] : Skipping file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
cause it exists already

As you can imagine, with a big domain model, these messages just scroll on and on and really seem to slow things down.  :(

btw, I am using Maven 2.1.0 and JDK 1.6_13.

Thanks!
--Polly


On Fri, Jun 26, 2009 at 1:51 AM, Karsten Thoms <karsten.thoms@...> wrote:
Hi Polly, 

when looking at the sources I recognized that it might be no issue of the Fornax Maven plugin. Debug output has changed there, but just regarding the debug output that the plugin does. This is now I mean correctly directed to the Plugin's context logger, and these debug messages are activated when running mvn -X install.
I saw that Sculptor overrides the log4j configuration for Surefire in their library example project like this:

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3</version>
<configuration>
<skip>false</skip>
<forkMode>pertest</forkMode>
<!-- <forkMode>once</forkMode> -->
<argLine>-Xms32m -Xmx1024m -Dlog4j.configuration=log4j-test.properties</argLine>
<excludes>
<exclude>**/IsolatedDatabaseTestCase.java</exclude>
</excludes>
</configuration>
</plugin>

Could you check if this would work for you, too?

Best wishes,
~Karsten

Am 25.06.2009 um 16:43 schrieb Polly C. Chang:

Thanks!

--Polly


On Thu, Jun 25, 2009 at 2:21 AM, Karsten Thoms <thoms@...> wrote:
Hi Polly,

logging has been changed to Commons Logging. I will change this back next week, maybe I can already deploy a snapshot tomorrow.
Opened Bug: https://fornax.itemis.de/jira/browse/TOM-26

~Karsten


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Thursday, June 25, 2009 3:09:08 AM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer



------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by Karsten Thoms :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

H Polly,

Hmm, I have no idea why these messages suddenly appear. I do not think that it has something to do with the oAW M2 plugin. On my side I do not get the debug messages, must be a matter of log4j configuration taken from the classpath. I once experienced that log4j.properties wins before log4j.xml. In my project we have added a log4j configuration component to the workflow. This way we can control logging. I think this could be a useful standard component that I could add.

~Karsten

Am 26.06.2009 um 23:38 schrieb Polly C. Chang:

Hi Karsten,

I have the same setup for the Surefire plugin, and that works fine.  The problems is that before we get to the unit tests, when Maven is generating sources, there is tons of debug output from oAW and Hybridlabs Beautifier.  I put a log4j.xml file in src/main/resources and that still doesn't turn off the oAW messages (though I am able to turn off the Hybridlabs messages). 

Are you able to turn off all the "Opening file", "Skipping file" kind of debug messages?

[org.openarchitectureware.
xpand2.output.FileHandleImpl] : Opening file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
[org.openarchitectureware.xpand2.output.FileHandleImpl] : Skipping file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
cause it exists already

As you can imagine, with a big domain model, these messages just scroll on and on and really seem to slow things down.  :(

btw, I am using Maven 2.1.0 and JDK 1.6_13.

Thanks!
--Polly


On Fri, Jun 26, 2009 at 1:51 AM, Karsten Thoms <karsten.thoms@...> wrote:
Hi Polly, 

when looking at the sources I recognized that it might be no issue of the Fornax Maven plugin. Debug output has changed there, but just regarding the debug output that the plugin does. This is now I mean correctly directed to the Plugin's context logger, and these debug messages are activated when running mvn -X install.
I saw that Sculptor overrides the log4j configuration for Surefire in their library example project like this:

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3</version>
<configuration>
<skip>false</skip>
<forkMode>pertest</forkMode>
<!-- <forkMode>once</forkMode> -->
<argLine>-Xms32m -Xmx1024m -Dlog4j.configuration=log4j-test.properties</argLine>
<excludes>
<exclude>**/IsolatedDatabaseTestCase.java</exclude>
</excludes>
</configuration>
</plugin>

Could you check if this would work for you, too?

Best wishes,
~Karsten

Am 25.06.2009 um 16:43 schrieb Polly C. Chang:

Thanks!

--Polly


On Thu, Jun 25, 2009 at 2:21 AM, Karsten Thoms <thoms@...> wrote:
Hi Polly,

logging has been changed to Commons Logging. I will change this back next week, maybe I can already deploy a snapshot tomorrow.
Opened Bug: https://fornax.itemis.de/jira/browse/TOM-26

~Karsten


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Thursday, June 25, 2009 3:09:08 AM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Karsten,

Yes, I would love to see the log4j configuration component that you put in your workflow!  Logging is so frustrating otherwise.  Is this something that you created?  Please let me know if/when you share it.

Thanks!
--Polly


On Sat, Jun 27, 2009 at 7:42 AM, Karsten Thoms <karsten.thoms@...> wrote:
H Polly,

Hmm, I have no idea why these messages suddenly appear. I do not think that it has something to do with the oAW M2 plugin. On my side I do not get the debug messages, must be a matter of log4j configuration taken from the classpath. I once experienced that log4j.properties wins before log4j.xml. In my project we have added a log4j configuration component to the workflow. This way we can control logging. I think this could be a useful standard component that I could add.

~Karsten

Am 26.06.2009 um 23:38 schrieb Polly C. Chang:

Hi Karsten,

I have the same setup for the Surefire plugin, and that works fine.  The problems is that before we get to the unit tests, when Maven is generating sources, there is tons of debug output from oAW and Hybridlabs Beautifier.  I put a log4j.xml file in src/main/resources and that still doesn't turn off the oAW messages (though I am able to turn off the Hybridlabs messages). 

Are you able to turn off all the "Opening file", "Skipping file" kind of debug messages?

[org.openarchitectureware.
xpand2.output.FileHandleImpl] : Opening file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
[org.openarchitectureware.xpand2.output.FileHandleImpl] : Skipping file :
C:\projects\runtime\com.foo.model\src\main\java\com\foo\model\package.html
cause it exists already

As you can imagine, with a big domain model, these messages just scroll on and on and really seem to slow things down.  :(

btw, I am using Maven 2.1.0 and JDK 1.6_13.

Thanks!
--Polly


On Fri, Jun 26, 2009 at 1:51 AM, Karsten Thoms <karsten.thoms@...> wrote:
Hi Polly, 

when looking at the sources I recognized that it might be no issue of the Fornax Maven plugin. Debug output has changed there, but just regarding the debug output that the plugin does. This is now I mean correctly directed to the Plugin's context logger, and these debug messages are activated when running mvn -X install.
I saw that Sculptor overrides the log4j configuration for Surefire in their library example project like this:

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3</version>
<configuration>
<skip>false</skip>
<forkMode>pertest</forkMode>
<!-- <forkMode>once</forkMode> -->
<argLine>-Xms32m -Xmx1024m -Dlog4j.configuration=log4j-test.properties</argLine>
<excludes>
<exclude>**/IsolatedDatabaseTestCase.java</exclude>
</excludes>
</configuration>
</plugin>

Could you check if this would work for you, too?

Best wishes,
~Karsten

Am 25.06.2009 um 16:43 schrieb Polly C. Chang:

Thanks!

--Polly


On Thu, Jun 25, 2009 at 2:21 AM, Karsten Thoms <thoms@...> wrote:
Hi Polly,

logging has been changed to Commons Logging. I will change this back next week, maybe I can already deploy a snapshot tomorrow.
Opened Bug: https://fornax.itemis.de/jira/browse/TOM-26

~Karsten


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Thursday, June 25, 2009 3:09:08 AM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer



------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by Karsten Thoms-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

To give you a quick help here is the source:

import java.net.URL;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import org.openarchitectureware.workflow.WorkflowContext;
import org.openarchitectureware.workflow.issues.Issues;
import org.openarchitectureware.workflow.lib.AbstractWorkflowComponent2;
import org.openarchitectureware.workflow.monitor.ProgressMonitor;

/**
 * Use this workflow component to initialize the logging subsystem.
 *
 * <h2>Example</h2>
 *
 * <pre>
 * <component class="gts.ise.common.oaw.workflow.LoggingConfiguratorComponent">
 *   <log4jConfig value="log4j.xml"/>
 * </component>
 * </pre>
 *
 */
public class LoggingConfiguratorComponent extends AbstractWorkflowComponent2 {
        private static final Log LOG = LogFactory.getLog(LoggingConfiguratorComponent.class);
        private String log4jConfig;
        private URL log4jConfigURL;

        @Override
        protected void checkConfigurationInternal(Issues issues) {
                if (log4jConfig!=null) {
                        log4jConfigURL = Thread.currentThread().getContextClassLoader().getResource(log4jConfig);
                        if (log4jConfigURL==null) {
                                issues.addError("Invalid URL specified for 'log4jConfig'");
                        }
                }
        }

        @Override
        protected void invokeInternal(WorkflowContext ctx, ProgressMonitor mon,
                        Issues issues) {
                if (log4jConfigURL!=null) {
                        if (log4jConfig.endsWith(".xml")) {
                                DOMConfigurator.configure(log4jConfigURL);
                        } else if (log4jConfig.endsWith(".properties")) {
                                PropertyConfigurator.configure(log4jConfigURL);
                        }
                        LOG.info("Configured log4j with "+log4jConfig);
                }
        }

        /**
         * Sets the log4j configuration to be used.
         * @param log4jConfig Resource URL of the log4j configuration. The URL must end with
         * file extensions ".xml" or ".properties". The referred configuration must be loadable
         * by the current thread's context classloader.
         */
        public void setLog4jConfig(String log4jConfig) {
                this.log4jConfig = log4jConfig;
        }

}


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Monday, June 29, 2009 4:51:33 PM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Karsten,

That's great!  And would you mind sharing what the config looks like in the workflow? 

Thanks!
--Polly


On Mon, Jun 29, 2009 at 11:02 AM, Karsten Thoms <thoms@...> wrote:
To give you a quick help here is the source:

import java.net.URL;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import org.openarchitectureware.workflow.WorkflowContext;
import org.openarchitectureware.workflow.issues.Issues;
import org.openarchitectureware.workflow.lib.AbstractWorkflowComponent2;
import org.openarchitectureware.workflow.monitor.ProgressMonitor;

/**
 * Use this workflow component to initialize the logging subsystem.
 *
 * <h2>Example</h2>
 *
 * <pre>
 * &lt;component class=&quot;gts.ise.common.oaw.workflow.LoggingConfiguratorComponent&quot;&gt;
 *   &lt;log4jConfig value=&quot;log4j.xml&quot;/&gt;
 * &lt;/component&gt;
 * </pre>
 *
 */
public class LoggingConfiguratorComponent extends AbstractWorkflowComponent2 {
       private static final Log LOG = LogFactory.getLog(LoggingConfiguratorComponent.class);
       private String log4jConfig;
       private URL log4jConfigURL;

       @Override
       protected void checkConfigurationInternal(Issues issues) {
               if (log4jConfig!=null) {
                       log4jConfigURL = Thread.currentThread().getContextClassLoader().getResource(log4jConfig);
                       if (log4jConfigURL==null) {
                               issues.addError("Invalid URL specified for 'log4jConfig'");
                       }
               }
       }

       @Override
       protected void invokeInternal(WorkflowContext ctx, ProgressMonitor mon,
                       Issues issues) {
               if (log4jConfigURL!=null) {
                       if (log4jConfig.endsWith(".xml")) {
                               DOMConfigurator.configure(log4jConfigURL);
                       } else if (log4jConfig.endsWith(".properties")) {
                               PropertyConfigurator.configure(log4jConfigURL);
                       }
                       LOG.info("Configured log4j with "+log4jConfig);
               }
       }

       /**
        * Sets the log4j configuration to be used.
        * @param log4jConfig Resource URL of the log4j configuration. The URL must end with
        * file extensions ".xml" or ".properties". The referred configuration must be loadable
        * by the current thread's context classloader.
        */
       public void setLog4jConfig(String log4jConfig) {
               this.log4jConfig = log4jConfig;
       }

}


----- Original Message -----
From: "Polly C. Chang" <polly.c.chang@...>
To: fornax-developer@...
Sent: Monday, June 29, 2009 4:51:33 PM (GMT+0100) Europe/Berlin
Subject: Re: [Fornax-developer] logging with fornax-oaw-m2-plugin

------------------------------------------------------------------------------


------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by Karsten Thoms :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

<component class="xxx.xxx.xxx.LoggingConfiguratorComponent">
     <log4jConfig value="path/to/log4j.xml"/>
</component>



------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Re: logging with fornax-oaw-m2-plugin

by polly.c.chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks!!

--Polly


On Tue, Jun 30, 2009 at 6:25 PM, Karsten Thoms <karsten.thoms@...> wrote:
<component class="xxx.xxx.xxx.LoggingConfiguratorComponent">
    <log4jConfig value="path/to/log4j.xml"/>
</component>



------------------------------------------------------------------------------
_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer


------------------------------------------------------------------------------

_______________________________________________
Fornax-developer mailing list
Fornax-developer@...
https://lists.sourceforge.net/lists/listinfo/fornax-developer