NET Logging Library
LogObject<T> Method (Log)
Example 



KellermanSoftware.NetLoggingLibrary Namespace > Log Class : LogObject<T> Method
Log an object of any type
Syntax
Public Shared Function LogObject(Of T As Class)( _
   ByVal level As LoggingLevel, _
   ByVal value As T _
) As LogResponse
Dim level As LoggingLevel
Dim value As T
Dim value As LogResponse
 
value = Log.LogObject(Of T)(level, value)
public static LogResponse LogObject<T>( 
   LoggingLevel level,
   T value
)
where T: class
public:
static LogResponse^ LogObjectgeneric<typename T>
( 
   LoggingLevel level,
   T^ value
) 
where T: ref class

Parameters

level
value

Type Parameters

T
Example
//Licensed Mode
//Log.UserName = "User Name From Receipt";
//Log.LicenseKey = "LicenseKey From Receipt";            
 
//Clear all configuration
Log.ResetConfiguration();
 
//Add a new target, you can also define targets in an xml file, app.config, or web.config
FileTarget fileTarget = new FileTarget(Environment.CurrentDirectory + "\\fileLogger.txt");
Log.Config.Targets.Add(fileTarget);
 
//Create customer object
Customer oCustomer = new Customer();
 
//Assign value to object
oCustomer.ID = 1;
oCustomer.Name = "Peter";
 
//Log oCustomer to Log
Log.LogObject(LoggingLevel.DEBUG, oCustomer);
'Licensed Mode
'Log.UserName = "User Name From Receipt";
'Log.LicenseKey = "LicenseKey From Receipt";            
 
'Clear all configuration
Log.ResetConfiguration()
 
'Add a new target, you can also define targets in an xml file, app.config, or web.config
Dim fileTarget As New FileTarget(Environment.CurrentDirectory & "\fileLogger.txt")
Log.Config.Targets.Add(fileTarget)
 
'Create customer object
Dim oCustomer As New Customer()
 
'Assign value to object
oCustomer.ID = 1
oCustomer.Name = "Peter"
 
'Log oCustomer to Log
Log.LogObject(LoggingLevel.DEBUG, oCustomer)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Log Class
Log Members