I agree with Mark, it happen to us while testing a client app; because the error was only printing to the console we never knew of the problem with our agent. It was a coincidence that I brought the app in the debugger and saw the console stack trace.
For abnormal conditions I think having some kind of event would be good. Wil -----Original Message----- From: Mark Gorokhov [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2008 9:33 AM To: Frank Fock Cc: Wilson Burgos; [email protected] Subject: RE: [SNMP4J] SnmpRequest.java not logging errors If the error in the agent is not abnormal it should be processed. If the error triggers printStackTrace() the error cannot be processed. In this case printing it to console makes no sense because console on a server is not visible and never monitored in production environment. This problem will never become known because it is never exposed. I think that the same approach should be taken for logging error conditions. Consider that log is never checked in production. This might be because of bad practice, or because the production server cannot be accessed, or because of the size of the log. Who could read millions of log lines on regular bases and decide where is a real problem? My preference is to notify about any abnormal condition some registered listeneres. These listeners in the main application should decide how to process the event or ignore it. I think that any 3rd party library should not use printStackTrace(). Also silent error conditions logging should be discouraged. Use notifications (event+listener) to the caller or throwing XxxxRuntimeException is preferred. Mark G -----Original Message----- From: Frank Fock [mailto:[EMAIL PROTECTED] Sent: Saturday, August 02, 2008 2:10 AM To: Mark Gorokhov Cc: Wilson Burgos; [email protected] Subject: Re: [SNMP4J] SnmpRequest.java not logging errors Hi, There is IMHO no abnormal program event that is "logged" to console and not forwarded to the logging adapter. The event below is a *normal* program event, since returning a SNMP error status is a normal task of a SNMP agent. So, printing the stacktrace here in debug mode is for debugging only, or do you want to log each SNMP error returned by the agent in production? Best regards, Frank Mark Gorokhov schrieb: > I support this request to remove all printStackTrace() from > SNMP4J code and use only RuntimeExceptions. Other option is to > add error event listeners and let them decide what to do > with the problem. > > Mark G. > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Wilson Burgos > Sent: Friday, August 01, 2008 1:16 PM > To: [email protected] > Subject: [SNMP4J] SnmpRequest.java not logging errors > > Hello, > I'm using SNMP4j and I can't seem to log SNMP errors when debug > is enabled. I found out the SnmpRequest.java is dumping them to the > console only. Is this the intended behavior not log error messages? > > public void requestStatusChanged(RequestStatusEvent event) { > int newStatus = event.getStatus().getErrorStatus(); > setErrorStatus(newStatus); > if (logger.isDebugEnabled() && > (newStatus != SnmpConstants.SNMP_ERROR_SUCCESS)) { > new Exception("Error '"+ > > PDU.toErrorStatusText(event.getStatus().getErrorStatus())+ > "' generated at: "+vb).printStackTrace(); > } > } > > Thanks, > Wil > _______________________________________________ > SNMP4J mailing list > [email protected] > http://lists.agentpp.org/mailman/listinfo/snmp4j > _______________________________________________ > SNMP4J mailing list > [email protected] > http://lists.agentpp.org/mailman/listinfo/snmp4j > _______________________________________________ SNMP4J mailing list [email protected] http://lists.agentpp.org/mailman/listinfo/snmp4j
