@Log annotation

26 / Sep / 2012 by Mohit Garg 2 comments

@Log : This annotation provides the log object in groovy class. By using it you don’t need to create the Logger object, it automatically provides log object.

Example:

import groovy.util.logging.Log

@Log
class Person {
    String name
    String address
    String city

    public void logDetails(){
        log.info("Name:::${name}--->Address ::: ${address}---> city :::${city}")
    }
}

new Person(name:"Mohit Garg",address:"Address",city: "city").logDetails()

It logs the details of the person object.

Hope this will help you :)

FOUND THIS USEFUL? SHARE IT

comments (2)

Leave a comment -