Monica. Shiralkar wrote:whenever in the code it gave me a compile time error: e.g It should throw IO error, I enclosed code with try catch block.
Rule #1 of catching exceptions: don't
Rule #2 of catching exceptions: violate rule #1 only if you have something that needs to be done to handle the exception at that level
I don't understand the need for custom exceptions at all.
I don't understand the need for custom exceptions at all.
Monica. Shiralkar wrote:-->Removed all try catch blocks from methods and replaced by throws clause. I am catching the exceptions only in main method.
-> In the catch block I am replacing e.printStacktrace by log.info. I am not clear that from the catch block is it better to have log.info
with some info Or is it better to throw your own exceptions from here.
-> For logging I am writing logs to a folder. I am thinking what should be the location of these logs folder
How you present errors to your user audience depends upon that audience. Showing an end user a stack trace is almost never an appropriate action.
That entirely depends upon the needs of the application.
Monica. Shiralkar wrote:
How you present errors to your user audience depends upon that audience. Showing an end user a stack trace is almost never an appropriate action.
The application is a core java application running through a scheduler. It will populate records in database.
Suppose the log folder grows to a very big size that it can no more write to that folder.
That doesn't address the issue. Who is the audience of this application? Who will be looking at the errors? What do they need to see?
Investigate the use of a logger such as Log4J and "rolling" appenders.
Also, carefully inspect your logging to make sure that what you are logging is appropriate. Producing reams of useless logging doesn't do anybody any good.
Monica. Shiralkar wrote:
This program will just populate data in database. Another program (not in java) will be displaying data to the user through reporting but that is some separate program.
Monica. Shiralkar wrote:I am using log4j. Suppose for some reason it is not able to write to that log file.So will the whole program fail to execute in that case or only the log wont be captured?
This still doesn't answer Bear's question though. Are the people that will read the logs (however they get displayed) technical people, or non-technical people. What do they need to know about the error? What will they do when they see and error? Do they need a full stack trace, or just an overview of the problem? All of these questions need an answer before you can decide what needs to be logged
Monica. Shiralkar wrote:
This still doesn't answer Bear's question though. Are the people that will read the logs (however they get displayed) technical people, or non-technical people. What do they need to know about the error? What will they do when they see and error? Do they need a full stack trace, or just an overview of the problem? All of these questions need an answer before you can decide what needs to be logged
If there is some issue with the data being not populated in database, they will ask me to check why my program did not function properly.At that time I will have to check the logs. No one has asked me to implement logs but I think I would require logs for this reason.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |