Jump to content

Log to file


Recommended Posts

Posted

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.

Posted (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 by dmmslaver
Posted (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 by Explv
  • Like 1
Posted (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
It allows it except it needs to be in c:/users/yourname/osbot/data

Also explv provided the method for it from the api :p

Edited by Vilius

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...