cancel
Showing results for 
Search instead for 
Did you mean: 

how to handle logging in groovy scripts

klaasdeboer
Champ on-the-rise
Champ on-the-rise

How can i access the logger from a groovy script?

Currently we use stdout (System.out.println("a log message")) in our groovy scripttasks. We want to move away from stdout logging and would like to use a the logger available in javascript scripttaks for example.

Or even better: can we define our own logfile and write to this?

1 ACCEPTED ANSWER

klaasdeboer
Champ on-the-rise
Champ on-the-rise

ok found out how to do it. Add the following to your script:

import org.slf4j.*;
Logger logger = LoggerFactory.getLogger("org.some.thing");
logger.debug("slf4j - logger.debug -- Hello world.");

View answer in original post

2 REPLIES 2

klaasdeboer
Champ on-the-rise
Champ on-the-rise

ok found out how to do it. Add the following to your script:

import org.slf4j.*;
Logger logger = LoggerFactory.getLogger("org.some.thing");
logger.debug("slf4j - logger.debug -- Hello world.");

EddieMay
World-Class Innovator
World-Class Innovator

Hi @klaasdeboer ,

Thanks for posting this solution - will be helpful to other users.

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!