Jump to content

Copy log to txt


kadiem

Recommended Posts

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 by Explv
  • Like 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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 by kadiem
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...