Jump to content

Log to file


dmmslaver

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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