kadiem Posted August 20, 2017 Posted August 20, 2017 Is there anyway to make the script copy all logs like this one into txt file? [INFO][Bot #1][08/21 12:51:53 AM]: WebWalkingEvent; We have reached the final destination! [INFO][Bot #1][08/21 12:51:53 AM]: Current money stock 662459 [INFO][Bot #1][08/21 12:52:00 AM]: Current money stock 662459
Fratem Posted August 20, 2017 Posted August 20, 2017 https://stackoverflow.com/questions/15758685/how-to-write-logs-in-text-file-when-using-java-util-logging-logger
dreameo Posted August 20, 2017 Posted August 20, 2017 Hmm.. not sure if true but I've heard a couple of times that I/O is blocked by the client.
Explv Posted August 21, 2017 Posted August 21, 2017 (edited) 9 hours ago, kadiem said: Is there anyway to make the script copy all logs like this one into txt file? [INFO][Bot #1][08/21 12:51:53 AM]: WebWalkingEvent; We have reached the final destination! [INFO][Bot #1][08/21 12:51:53 AM]: Current money stock 662459 [INFO][Bot #1][08/21 12:52:00 AM]: Current money stock 662459 If it is your own script, just write to a file instead of the logger. If it isn't, you could run the bot via the command line in debug mode using the -debug flag and then redirect the output to a file by using > logfile.txt at the end of the command. java -jar ....... -debug ..... > logfile.txt Edited August 21, 2017 by Explv 1
kadiem Posted August 21, 2017 Author Posted August 21, 2017 6 hours ago, Explv said: If it is your own script, just write to a file instead of the logger. If it isn't, you could run the bot via the command line in debug mode using the -debug flag and then redirect the output to a file by using > logfile.txt at the end of the command. java -jar ....... -debug ..... > logfile.txt It's my script i already tried this : try { File file = new File("Test.txt"); if(!file.exists()) { file.createNewFile(); } PrintWriter pw = new PrintWriter(file); pw.println("Test"); pw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } But it's giving me permission error is there another way?
Explv Posted August 21, 2017 Posted August 21, 2017 1 minute ago, kadiem said: It's my script i already tried this : try { File file = new File("Test.txt"); if(!file.exists()) { file.createNewFile(); } PrintWriter pw = new PrintWriter(file); pw.println("Test"); pw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } But it's giving me permission error is there another way? You can only create files in the OSBot data directory. The path for this directory can be retrieved using getDirectoryData(), I think it's in the Script class?
kadiem Posted August 21, 2017 Author Posted August 21, 2017 (edited) 9 minutes ago, Explv said: You can only create files in the OSBot data directory. The path for this directory can be retrieved using getDirectoryData(), I think it's in the Script class? I changed pathname to getDirectoryData()+"Test.txt" and it worked thank you so much!! Edited August 21, 2017 by kadiem