| Author |
Log4j tracking
|
Saral Saxena
Ranch Hand
Joined: Apr 22, 2011
Posts: 200
|
|
Hi Folks,
I have one query that is as we use log4j in our web applications and other appliations and in the back end we check the logs to cross check all the events in a sequence , can we use that same log4j in our normal java class, lets say I have a simple java class with a simple System.out.println statement Can I use log4j there and can cross check all the events that have happened , like how the class is loaded and all the jvm related activities in a log file..!!
|
 |
Saral Saxena
Ranch Hand
Joined: Apr 22, 2011
Posts: 200
|
|
Saral Saxena wrote:Hi Folks,
I have one query that is as we use log4j in our web applications and other appliations and in the back end we check the logs to cross check all the events in a sequence , can we use that same log4j in our normal java class, lets say I have a simple java class with a simple System.out.println statement Can I use log4j there and can cross check all the events that have happened , like how the class is loaded and all the jvm related activities in a log file..!!
Hi Guys,
Can anybody please guide me on this..!!
|
 |
Praveen Kumar M K
Ranch Hand
Joined: Jul 03, 2011
Posts: 148
|
|
Hi,
Using log4j in the way that you mean, its not possible to capture jvm related activities. If you use log4j in a normal java class you will get logs which you yourself intend to print. For example : log("Enter method"), log("Start doing something"), log("Finish"), log("Exit method").
For jvm logs you can either look at Console or direct the output of that to a text file.
Regards,
Praveen.
|
 |
Saral Saxena
Ranch Hand
Joined: Apr 22, 2011
Posts: 200
|
|
Barney Balboa wrote:Hi,
For jvm logs you can either look at Console or direct the output of that to a text file.
Regards,
Praveen.
Hi ,
Please advise me when I execute my java class, I want to check the background activities that are happeing behind the scenes the same thing that you are talking about directing the output to a file of jvm logs, How Can I do that , Please advise..!!
|
 |
Praveen Kumar M K
Ranch Hand
Joined: Jul 03, 2011
Posts: 148
|
|
Thanks for asking me this question, made me google around a bit
Use java -verbose:class <classname> or just add -verbose:class in your eclipse VM arguments and see what you get.
|
 |
Saral Saxena
Ranch Hand
Joined: Apr 22, 2011
Posts: 200
|
|
Barney Balboa wrote:Thanks for asking me this question, made me google around a bit
Use java -verbose:class <classname> or just add -verbose:class in your eclipse VM arguments and see what you get.
Hi Barney,
Thanks a lot i have tried a simple class
and after setting the vm arguements i get the following jvm logs on console ...
I want that these logs that are being displayed on console should be written in a log file how to save these logs on a file...!!
|
 |
Rob Spoor
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18370
|
|
Saral Saxena wrote:
Saral Saxena wrote:Hi Folks,
I have one query that is as we use log4j in our web applications and other appliations and in the back end we check the logs to cross check all the events in a sequence , can we use that same log4j in our normal java class, lets say I have a simple java class with a simple System.out.println statement Can I use log4j there and can cross check all the events that have happened , like how the class is loaded and all the jvm related activities in a log file..!!
Hi Guys,
Can anybody please guide me on this..!!
PatienceIsAVirtue. Seriously, you can't even wait 6 hours?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Saral Saxena
Ranch Hand
Joined: Apr 22, 2011
Posts: 200
|
|
Hi Guys ,
Please guide me how the jvm logs generated on console that I want to write in a file such as log file, for that what steps I need to follow please advise ..!!
|
 |
Praveen Kumar M K
Ranch Hand
Joined: Jul 03, 2011
Posts: 148
|
|
Let me re-visit the problem again. You want the console output displayed above in a text file? You can use a redirection operator on command line and point it into a text file right...
Please do reply if that was not what you wanted.
|
 |
 |
|
|
subject: Log4j tracking
|
|
|