You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Omar@Gmail" <om...@googlemail.com> on 2014/01/03 10:44:06 UTC
Maven Plugin Logging
Hi All,
I implemented my own Maven plugin mojo in which I used log4j + slf4j. In
the plugin project I have included the correct jars and can see correct
logging of statements from code.
Now I want use this new maven plugin in another client project but having
trouble getting it to work correctly.
In the plugin itself I have included a log4j.properties under
src/main/resources which works fine as mentioned above. But when I try to
include the plugin in another client project the log file is not being
created.
The question is what else do I have to try or do to get this working
correctly?
Thank you.
Omar
Re: Maven Plugin Logging
Posted by Cleuton Sampaio <cl...@gmail.com>.
You should use the object returned by the getLog method, which is an implementation of
org.apache.maven.plugin.logging
Interface Log
It is exactly the architecture that I am using in my own plugin: jQana (Github). It is still in early dev stage, but I am facing that same problem. The only way to solve is to use the Log implemantation returned by getLog.
Here I am instantiating my pojo from the mojo, and passing the Log Object:
DefaultProjectProcessor dpp = new DefaultProjectProcessor(new Context());
dpp.setLog(getLog());
Here I am logging in my pojo:
// using maven plugin logger
switch (type) {
case INFO:
this.log.info(msg);
break;
case DEBUG:
this.log.debug(msg);
break;
case ERROR:
this.log.error(msg);
}
Cleuton Sampaio
> Em 03/01/2014, às 18:46, "Omar@Gmail" <om...@googlemail.com> escreveu:
>
> Thanks Cleuton, in my custom plugin which I developed I have a Mojo that
> extends AbstractMojo but this Mojo delegates to a Pojo. Both the Mojo and
> Pojo each have their won logger. In this case does your suggestion still
> stand? can you suggest some simple steps to use the AbstractMojo getLog()
> method.
>
> Omar
>
>
>> On 3 January 2014 16:02, Cleuton Sampaio <cl...@gmail.com> wrote:
>>
>> Did you based your mojo on class AbstractMojo ? If you did, then you
>> should use the getLog() method. See:
>>
>>
>> http://maven.apache.org/ref/2.2.1/maven-plugin-api/apidocs/org/apache/maven/plugin/AbstractMojo.html
>>
>> Cleuton Sampaio
>>
>>>> Em 03/01/2014, às 07:44, "Omar@Gmail" <om...@googlemail.com>
>>> escreveu:
>>>
>>> Hi All,
>>>
>>> I implemented my own Maven plugin mojo in which I used log4j + slf4j. In
>>> the plugin project I have included the correct jars and can see correct
>>> logging of statements from code.
>>>
>>> Now I want use this new maven plugin in another client project but having
>>> trouble getting it to work correctly.
>>>
>>> In the plugin itself I have included a log4j.properties under
>>> src/main/resources which works fine as mentioned above. But when I try to
>>> include the plugin in another client project the log file is not being
>>> created.
>>>
>>> The question is what else do I have to try or do to get this working
>>> correctly?
>>>
>>> Thank you.
>>> Omar
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
Re: Maven Plugin Logging
Posted by "Omar@Gmail" <om...@googlemail.com>.
Thanks Cleuton, in my custom plugin which I developed I have a Mojo that
extends AbstractMojo but this Mojo delegates to a Pojo. Both the Mojo and
Pojo each have their won logger. In this case does your suggestion still
stand? can you suggest some simple steps to use the AbstractMojo getLog()
method.
Omar
On 3 January 2014 16:02, Cleuton Sampaio <cl...@gmail.com> wrote:
> Did you based your mojo on class AbstractMojo ? If you did, then you
> should use the getLog() method. See:
>
>
> http://maven.apache.org/ref/2.2.1/maven-plugin-api/apidocs/org/apache/maven/plugin/AbstractMojo.html
>
> Cleuton Sampaio
>
> > Em 03/01/2014, às 07:44, "Omar@Gmail" <om...@googlemail.com>
> escreveu:
> >
> > Hi All,
> >
> > I implemented my own Maven plugin mojo in which I used log4j + slf4j. In
> > the plugin project I have included the correct jars and can see correct
> > logging of statements from code.
> >
> > Now I want use this new maven plugin in another client project but having
> > trouble getting it to work correctly.
> >
> > In the plugin itself I have included a log4j.properties under
> > src/main/resources which works fine as mentioned above. But when I try to
> > include the plugin in another client project the log file is not being
> > created.
> >
> > The question is what else do I have to try or do to get this working
> > correctly?
> >
> > Thank you.
> > Omar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Maven Plugin Logging
Posted by Cleuton Sampaio <cl...@gmail.com>.
Did you based your mojo on class AbstractMojo ? If you did, then you should use the getLog() method. See:
http://maven.apache.org/ref/2.2.1/maven-plugin-api/apidocs/org/apache/maven/plugin/AbstractMojo.html
Cleuton Sampaio
> Em 03/01/2014, às 07:44, "Omar@Gmail" <om...@googlemail.com> escreveu:
>
> Hi All,
>
> I implemented my own Maven plugin mojo in which I used log4j + slf4j. In
> the plugin project I have included the correct jars and can see correct
> logging of statements from code.
>
> Now I want use this new maven plugin in another client project but having
> trouble getting it to work correctly.
>
> In the plugin itself I have included a log4j.properties under
> src/main/resources which works fine as mentioned above. But when I try to
> include the plugin in another client project the log file is not being
> created.
>
> The question is what else do I have to try or do to get this working
> correctly?
>
> Thank you.
> Omar
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org