Forum Discussion

nngrjg's avatar
nngrjg
Occasional Visitor
4 years ago

how can i log all the log.info detail to a single file

consider i have around 10 log.info in an script and i need to log all the 10 in a single file.could you please proved your suggestion please

1 Reply

  • richie's avatar
    richie
    Community Hero

    Hey nngrjg 

     

    I've put something VERY basic together where it'll write 10 values to a flat file in a single column - you didn't say anything about infile presentation or anything like that - im sure the real coders would do something more efficient/better - but without knowing more details -  this will do the job of what you asked.

     

    //below script will write 10 values in a single column in the file in a newly created file 
    
    java.io.File
    
    File file = new File("C://Users/Rich/Downloads/groovytest.txt")
    file.write("valuefrom1stloggedvariable\n")
    file.append("valuefrom2ndloggedvariable\n")
    file.append("valuefrom3rdloggedvariable\n")
    file.append("valuefrom4thloggedvariable\n")
    file.append("valuefrom5thloggedvariable\n")
    file.append("valuefrom6thloggedvariable\n")
    file.append("valuefrom7thloggedvariable\n")
    file.append("valuefrom8thloggedvariable\n")
    file.append("valuefrom9thloggedvariable\n")
    file.append("valuefrom10thloggedvariable\n")
    //log.info(file.text)

     

    Cheers,

     

    Rich