-2

I am new to log files.
I want to log exceptions thrown while running the application and some other statements when a user uses my java swing application.
Using logs I believe that some problems which I haven't been able to handle and find in my application can be identified and solved by looking at the logs.
As I think, the best way to get such statements out of the application is creating log files.
I read some articles and found something called log4j.
Please any one let me know more about log files(advantages) and good sample codes in a swing application showing getting statements to an external file.

James A Mohler
  • 10,562
  • 14
  • 41
  • 65
Débora
  • 5,390
  • 21
  • 84
  • 159
  • Start by reading this link http://stackoverflow.com/questions/2727500/log4j-vs-system-out-println-logger-advantages then look here http://logging.apache.org/log4j/1.2/manual.html and then here http://logging.apache.org/log4j/1.2/faq.html Practically log4j is used almost the same way whether its Swing application or any other application. – mprabhat Dec 03 '11 at 08:08

1 Answers1

2

The main advantage of Log4j is that allow logging using different levels and different output type(Appenders), the library is fully configurable with its log4j.properties where you can define its configuration.

Another advantage of log4j is that log files contain semi structured information about application problems and exists several applications to view and filter a log4j generated files.

Take a look here for a log4j configured with a File Appender example .

aleroot
  • 66,082
  • 27
  • 164
  • 205