By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,915 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,915 IT Pros & Developers. It's quick & easy.

Redirecting Tomcat console output into a textfile

P: 10
Hai everybody,

how can i redirect tomcat console output into a text file.

I want to print all the error output into the textfile.Help me,

thanks in advance......
Jul 4 '07 #1
Share this Question
Share on Google+
13 Replies


Motoma
Expert 2.5K+
P: 3,235
Hai everybody,

how can i redirect tomcat console output into a text file.

I want to print all the error output into the textfile.Help me,

thanks in advance......
What operating system are you running Tomcat on?
Jul 6 '07 #2

P: 10
What operating system are you running Tomcat on?
Thank you for your reply.

We are using windows xp operating system.

Thanks in advance...
Jul 7 '07 #3

Motoma
Expert 2.5K+
P: 3,235
Thank you for your reply.

We are using windows xp operating system.

Thanks in advance...
Is there a log directory in your Tomcat install directory?
Jul 8 '07 #4

P: 10
Is there a log directory in your Tomcat install directory?

logs directory is there in the tomcat directory.

Thanks in advance.
Jul 9 '07 #5

Motoma
Expert 2.5K+
P: 3,235
logs directory is there in the tomcat directory.

Thanks in advance.
And error output is not being placed in that directory?
Jul 9 '07 #6

P: 10
I'm asking tht whatever we print in console output using System.out.println should also be stored in a log file for future verification. How can we do that?
Do we have to apply some codings or we have change the settings in the xml file.
Pls provide me answers. It would be so helpful.
Jul 11 '07 #7

Motoma
Expert 2.5K+
P: 3,235
Why not create a function that both writes output to a file and to stdout?
Jul 11 '07 #8

P: 10
Why not create a function that both writes output to a file and to stdout?
Thats why i am asking....

Give me some codings for do that

This is very helpful for me...
Jul 12 '07 #9

Motoma
Expert 2.5K+
P: 3,235
I'm going to move this thread to the Java Forum, because the experts there will be able to help you better than I.
Jul 12 '07 #10

100+
P: 127
Is it resolved?


If not, How big is your application? I think you need to do a work around for making the SOPs printed into a log file rather than or along with the console output.
Jul 13 '07 #11

P: 10
Is it resolved?



If not, How big is your application? I think you need to do a work around for making the SOPs printed into a log file rather than or along with the console output.

Thanks for your reply.

No.I don't know the answer.

I want to print all the error messages and System.out.print messages in the text file.

Whatever print in the tomcat server , I want to get in that text file.

Thanks in Advance....
Jul 13 '07 #12

10K+
P: 13,264
Thanks for your reply.

No.I don't know the answer.

I want to print all the error messages and System.out.print messages in the text file.

Whatever print in the tomcat server , I want to get in that text file.

Thanks in Advance....
This article explains how to write to files, however, I suggest you also take a look at the Logger.
Jul 13 '07 #13

100+
P: 127
Thanks for your reply.

No.I don't know the answer.

I want to print all the error messages and System.out.print messages in the text file.

Whatever print in the tomcat server , I want to get in that text file.

Thanks in Advance....
Thats fine. As the admin pointed out, you may please read the articles about how to read and write into a file and about the Java Logging API.

You need to understand one thing that whatever you print using SOP (System.out.println or System.err.println) they will ONLY get printed on console (screen).

If at all you want to divert or delegate the output to some other file (you may call it as a log file or text file), you have to manually replace all the SOPs with a method call which would in turn write it into a log file.

After going through the Java Logging API, what you can do is,

(i) write one class with a method for logging (as per the Logging API) with the specific properties being set (filename etc).

(ii) Manually invoke this method appropriately (if its static call with the classname; if not call with its instance) everywhere you have the System.out.println or System.err.println statements in your application.


If you want the output lines printed on the Console with respect to the status of Tomcat (say during its startup), you dont need to worry. Because, all information are by default getting stored into a log file with the "machine name & date and time at which it was running" (for example, "localhost_log.2007-06-26" for the information logged while running on localhost (same machine) at 26th June 2007)).

The log file would be stored in a directory called "logs" which would be present under your TOMCAT_ROOT directory where you have installed Tomcat.

Hope this helps!
Jul 13 '07 #14

Post your reply

Sign in to post your reply or Sign up for a free account.