NET Logging Library
GetTargetByName Method (Log)
Example 



KellermanSoftware.NetLoggingLibrary Namespace > Log Class : GetTargetByName Method
Get a target by its name
Syntax
Public Shared Function GetTargetByName( _
   ByVal name As String _
) As BaseTarget
Dim name As String
Dim value As BaseTarget
 
value = Log.GetTargetByName(name)
public static BaseTarget GetTargetByName( 
   string name
)
public:
static BaseTarget^ GetTargetByName( 
   String^ name
) 

Parameters

name
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);
 
//Get the target by the name
FileTarget result = (FileTarget)Log.GetTargetByName("FileTarget");
'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)
 
'Get the target by the name
Dim result As FileTarget = CType(Log.GetTargetByName("FileTarget"), FileTarget)
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