Click or drag to resize

NeonController Class

Enhances the Controller class to simplify and enhance web application logging.
Inheritance Hierarchy
Controller
  Neon.WebNeonController

Namespace:  Neon.Web
Assembly:  Neon.Web (in Neon.Web.dll) Version: 2.1.0
Syntax
public abstract class NeonController : Controller, 
	INeonLogger

The NeonController type exposes the following members.

Constructors
  NameDescription
Protected methodNeonController
Constructor.
Top
Properties
  NameDescription
Protected propertyActivityId
Returns the opaque globally unique activity ID for the current operation.
Public propertyContextId
Returns the logger's context ID or null.
Protected propertyInternalActivityId
Internal use only: Return's the request's X-Request-ID header value or null. Application services should use ActivityId which guarantees that a valid activity ID will be returned.
Public propertyIsLogCriticalEnabled
Returns true if critical logging is enabled.
Public propertyIsLogDebugEnabled
Returns true if debug logging is enabled.
Public propertyIsLogErrorEnabled
Returns true if error logging is enabled.
Public propertyIsLogInfoEnabled
Returns true if info logging is enabled.
Public propertyIsLogSErrorEnabled
Returns true if serror logging is enabled.
Public propertyIsLogSInfoEnabled
Returns true if sinfo logging is enabled.
Public propertyIsLogTransientEnabled
Returns true if transient logging is enabled.
Public propertyIsLogWarnEnabled
Returns true if warn logging is enabled.
Top
Methods
  NameDescription
Public methodCritical(Object, String)
Public methodCritical(Object, Exception, String)
Public methodDebug(Object, String)
Public methodDebug(Object, Exception, String)
Public methodError(Object, String)
Public methodError(Object, Exception, String)
Public methodInfo(Object, String)
Public methodInfo(Object, Exception, String)
Public methodIsLogLevelEnabled
Indicates whether logging is enabled for a specific log level.
Public methodLogCritical(Object, String)
Logs a critical message.
Public methodLogCritical(Object, Exception, String)
Logs a critical message along with exception information.
Public methodLogDebug(Object, String)
Logs a debug message.
Public methodLogDebug(Object, Exception, String)
Logs a debug message along with exception information.
Public methodLogError(Object, String)
Logs an error message.
Public methodLogError(Object, Exception, String)
Logs an error message along with exception information.
Public methodLogInfo(Object, String)
Logs an info message.
Public methodLogInfo(Object, Exception, String)
Logs an info message along with exception information.
Public methodLogSError(Object, String)
Logs an serror message.
Public methodLogSError(Object, Exception, String)
Logs an serror message along with exception information.
Public methodLogSInfo(Object, String)
Logs an sinfo message.
Public methodLogSInfo(Object, Exception, String)
Logs an sinfo message along with exception information.
Public methodLogTransient(Object, String)
Logs a transient message.
Public methodLogTransient(Object, Exception, String)
Logs a transient message along with exception information.
Public methodLogWarn(Object, String)
Logs a warn message.
Public methodLogWarn(Object, Exception, String)
Logs a warn message along with exception information.
Public methodSError(Object, String)
Public methodSError(Object, Exception, String)
Public methodSInfo(Object, String)
Public methodSInfo(Object, Exception, String)
Public methodTransient(Object, String)
Public methodTransient(Object, Exception, String)
Public methodWarn(Object, String)
Public methodWarn(Object, Exception, String)
Top
Extension Methods
  NameDescription
Public Extension MethodLogCritical(FuncObject)Overloaded.
Logs a critical message retrieved via a message function.
(Defined by LogExtensions.)
Public Extension MethodLogCritical(Exception)Overloaded.
Logs a critical exception.
(Defined by LogExtensions.)
Public Extension MethodLogDebug(FuncObject)Overloaded.
Logs a debug message retrieved via a message function.
(Defined by LogExtensions.)
Public Extension MethodLogDebug(Exception)Overloaded.
Logs a debug exception.
(Defined by LogExtensions.)
Public Extension MethodLogError(FuncObject)Overloaded.
Logs an error message retrieved via a message function.
(Defined by LogExtensions.)
Public Extension MethodLogError(Exception)Overloaded.
Logs an error exception.
(Defined by LogExtensions.)
Public Extension MethodLogInfo(FuncObject)Overloaded.
Logs an informational message retrieved via a message function.
(Defined by LogExtensions.)
Public Extension MethodLogInfo(Exception)Overloaded.
Logs an info exception.
(Defined by LogExtensions.)
Public Extension MethodLogTransient(FuncObject)Overloaded.
Logs a transient message retrieved via a message function.
(Defined by LogExtensions.)
Public Extension MethodLogTransient(Exception)Overloaded.
Logs a transient exception.
(Defined by LogExtensions.)
Public Extension MethodLogWarn(FuncObject)Overloaded.
Logs a warning message retrieved via a message function.
(Defined by LogExtensions.)
Public Extension MethodLogWarn(Exception)Overloaded.
Logs a warning exception.
(Defined by LogExtensions.)
Top
Remarks

This class provides two logging related enhancements. First, NeonController implements INeonLogger so that all of the standard logging methods are directly available in the context of the derived controller. Events will be logged with the module set to "Web-" prefixing the name of the controller.

The ActivityId property can also be used to easily correlate operations that span multiple systems and services. An activity is a globally unique string that can be used to corelate a parent operation with any decendent operations. For example, a parent operation such as get-weather may need to call several other web services to get-current-weather, get-forecast, get-weather-alerts,... and these child services may need to call other services. The essential idea here is to generate an activity ID for the parent operation, recursively pass this to any child operations and then include the activity ID in any logged errors or warnings.

This can be very useful operationally for diagnosing problems. A typical scanario is: a parent operation fails and an error is logged and the operator can then review the logs with the activity across all systems and services to disgnose exactly what happened.

The Neon framework and cluster have built-in mechanisms to make this easy. INeonLogger logging methods include activityId as first class parameters and the cluster pipeline implicitly process and persist activity-id fields from event streams.

The neon-proxy-public and neon-proxy-private services are also aware of activity IDs and will include these in the HTTP traffic logs and also generate new activity IDs for inbound requests that don't already have them. This value will be available as the ActivityId property.

To enable cross system/service activity correlation, you'll need to include the ActivityId as the X-Request-ID header in requests made to those systems. The JsonClient includes built-in methods that make this easy.

See Also