Jump to content

Copy log to txt


Recommended Posts

Posted

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

 

Posted (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 by Explv
  • Like 1
Posted
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?

Posted
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?

 

Posted (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 by kadiem

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