2015-07-03 56 views
0

我是Groovy腳本編程的新手。爲了排除故障/調試目的,我想將這些信息寫入日誌文件中。我必須按照以下骨架編寫我的實際代碼。登錄Groovy

import java.util.List; 
import com.test.build.api.scripting.XXX; 
**import import java.util.logging.Logger** 

class MyTest 
{ 
    **static Logger logger = Logger.getLogger (MyClass.class.getName());** 
def init() 
{ 
    // HERE I WANT TO LOG THAT INIT WAS CALLED 
    } 

    def destroy() 
     { 
     } 

      def process(List<XXX> xxxy) 
       { 
        // Reuse following skeleton for processing events 
         try 
          { 
          // Do Something 
        // HERE I WANT TO LOG THAT SOMETHING WAS DONE ABOVE 
          // Do Something 
        // HERE I WANT TO LOG THAT SOMETHING WAS DONE ABOVE 
          // Do Something 
        // HERE I WANT TO LOG THAT SOMETHING WAS DONE ABOVE 
          // Do Something 
          } 
       } 
     catch(InterruptedException e) 
     { 
     return 
      } 
      } 
      } 

這一切我要登錄一個文件即C:\ TEMP \ myscripting.log

有人能幫助我嗎?

+2

http://stackoverflow.com/questions/19868180/groovy-script-and-log4j –

回答

1

我個人推薦SLF4J

由於@tim_yates comented,log4j是偉大的。 我在我的groovy項目中使用了log4j。 tutorial是非常自我探索。