Groovy using log4j output

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Groovy using log4j output

Tronicek
Hi,

to automate group membership i wrote a Groovy script. It is called periodically via scheduler.
This script use log4j to write some informations at info and at warning level to the console and to a database table.

By now we are missing the output. It vanished since XWiki XE 1.6.
Can you tell me how to enable the output again, please?
Thanks.

A simple extract (snippet):

/* Groovy Class: $doc.fullName ([View Code>$doc.fullName?viewer=code]) #* */
import org.jboss.logging.Logger;
class UpdateGroupMembershipClass{
  def xwiki;
  def context;
  def doc;
  def log; // Logger
  void setXWiki(xwiki)
  {

    this.xwiki = xwiki;
    this.context = this.xwiki.getXWikiContext();
    this.doc = this.context.getDoc();
    this.log = Logger.getLogger("our.organization.XWiki." + this.doc.getFullName());
    log.info("XWiki context initialized.");
  }
  /* other methods ... */
}
/* *# */
Reply | Threaded
Open this post in threaded view
|

Re: Groovy using log4j output

Sergiu Dumitriu-2
Tronicek wrote:

> Hi,
>
> to automate group membership i wrote a Groovy script. It is called
> periodically via scheduler.
> This script use log4j to write some informations at info and at warning
> level to the console and to a database table.
>
> By now we are missing the output. It vanished since XWiki XE 1.6.
> Can you tell me how to enable the output again, please?
> Thanks.
>
> A simple extract (snippet):
>
> /* Groovy Class: $doc.fullName ([View Code>$doc.fullName?viewer=code]) #*
> */
> import org.jboss.logging.Logger;
> class UpdateGroupMembershipClass{
>   def xwiki;
>   def context;
>   def doc;
>   def log; // Logger
>   void setXWiki(xwiki)
>   {
>
>     this.xwiki = xwiki;
>     this.context = this.xwiki.getXWikiContext();
>     this.doc = this.context.getDoc();
>     this.log = Logger.getLogger("our.organization.XWiki." +
> this.doc.getFullName());
>     log.info("XWiki context initialized.");
>   }
>   /* other methods ... */
> }
> /* *# */
>

I guess this is a logger configuration setting (it doesn't print "info"
messages). You could either configure the logging system to print them,
or increase the importance of the message (log.error("XWiki context
initialized");)

--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Groovy using log4j output

Tronicek
Hi,

just in case someone need to write to JBoss console using XWiki Groovy.
Don't import the JBoss logger, use apache logger instead:

import org.apache.log4j.Logger;

Thanks,
R. Tronicek

Our environment
1.8 XE with XEM plugin
JBoss 1.4.1 & 1.4.2
Sergiu Dumitriu-2 wrote
Tronicek wrote:
> Hi,
>
> to automate group membership i wrote a Groovy script. It is called
> periodically via scheduler.
> This script use log4j to write some informations at info and at warning
> level to the console and to a database table.
>
> By now we are missing the output. It vanished since XWiki XE 1.6.
> Can you tell me how to enable the output again, please?
> Thanks.
>
> A simple extract (snippet):
>
> /* Groovy Class: $doc.fullName ([View Code>$doc.fullName?viewer=code]) #*
> */
> import org.jboss.logging.Logger;
> class UpdateGroupMembershipClass{
>   def xwiki;
>   def context;
>   def doc;
>   def log; // Logger
>   void setXWiki(xwiki)
>   {
>
>     this.xwiki = xwiki;
>     this.context = this.xwiki.getXWikiContext();
>     this.doc = this.context.getDoc();
>     this.log = Logger.getLogger("our.organization.XWiki." +
> this.doc.getFullName());
>     log.info("XWiki context initialized.");
>   }
>   /* other methods ... */
> }
> /* *# */
>

I guess this is a logger configuration setting (it doesn't print "info"
messages). You could either configure the logging system to print them,
or increase the importance of the message (log.error("XWiki context
initialized");)

--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users