dmmslaver Posted January 5, 2017 Share Posted January 5, 2017 How do I log to a file? This is imperative for debugging purposes yet it seems impossible. Quote Link to comment Share on other sites More sharing options...
Explv Posted January 5, 2017 Share Posted January 5, 2017 (edited) How do I log to a file? This is imperative for debugging purposes yet it seems impossible. Start the bot in debug mode from the command line and pipe to a file: java -jar "C:\Users\Username\Desktop\OSBot 2.4.107.jar" -debug (rest of params) > log_file.txt Edited January 5, 2017 by Explv Quote Link to comment Share on other sites More sharing options...
dmmslaver Posted January 5, 2017 Author Share Posted January 5, 2017 Start the bot in debug mode from the command line and pipe to a file: java -jar "C:\Users\Username\Desktop\OSBot 2.4.107.jar" -debug (rest of params) > log_file.txt Thank you is there somewhere i could have found that on my own? Quote Link to comment Share on other sites More sharing options...
Explv Posted January 5, 2017 Share Posted January 5, 2017 Thank you is there somewhere i could have found that on my own? Well I believe I answered the same question a while ago, I can't seem to find the thread however. Also an alternative solution would be to override the log method in the MethodProvider class (which your Script extends) to write to a file instead. Quote Link to comment Share on other sites More sharing options...
Botre Posted January 5, 2017 Share Posted January 5, 2017 This might inspire you http://osbot.org/forum/topic/93716-t13-introduction-to-simplog-lightweight-logging/ Quote Link to comment Share on other sites More sharing options...
dmmslaver Posted January 5, 2017 Author Share Posted January 5, 2017 (edited) Well I believe I answered the same question a while ago, I can't seem to find the thread however. Also an alternative solution would be to override the log method in the MethodProvider class (which your Script extends) to write to a file instead. That's what I tried however it doesn't seem to allow any type of file IO. @[member='Override'] public void onStart() { try { out = new FileOutputStream(new File(System.getProperty("user.home"), "osmodlog.txt")); logging = true; } catch (Throwable e) { log(e); } } out would still == null during onLoop with no exception thrown. weird but not for osbot lol Edited January 5, 2017 by dmmslaver Quote Link to comment Share on other sites More sharing options...
Explv Posted January 5, 2017 Share Posted January 5, 2017 (edited) That's what I tried however it doesn't seem to allow any type of file IO. @[member='Override'] public void onStart() { try { out = new FileOutputStream(new File(System.getProperty("user.home"), "osmodlog.txt")); logging = true; } catch (Throwable e) { log(e); } } out would still == null during onLoop with no exception thrown. weird but not for osbot lol You can only write files in the data directory, which can be retrieved using this method: http://osbot.org/api/org/osbot/rs07/script/Script.html#getDirectoryData-- Edited January 5, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Vilius Posted January 5, 2017 Share Posted January 5, 2017 (edited) That's what I tried however it doesn't seem to allow any type of file IO. @[member='Override'] public void onStart() { try { out = new FileOutputStream(new File(System.getProperty("user.home"), "osmodlog.txt")); logging = true; } catch (Throwable e) { log(e); } }out would still == null during onLoop with no exception thrown. weird but not for osbot lolIt allows it except it needs to be in c:/users/yourname/osbot/dataAlso explv provided the method for it from the api :p Edited January 5, 2017 by Vilius Quote Link to comment Share on other sites More sharing options...