FCFL.NET Common Library - API Reference
GetLogger(String) Method
Example 

The name of the logger to retrieve.
Retrieves a logger for the given logger name.
Syntax
'Declaration
 
Public Overloads Shared Function GetLogger( _
   ByVal loggerName As String _
) As Logger
public static Logger GetLogger( 
   string loggerName
)

Parameters

loggerName
The name of the logger to retrieve.

Return Value

The logger configured for the specified logger name.
Remarks
It is generally a good idea to declare a logger once at the top of your class as a static member. Though this method does very little and has very little impact on performance, it makes the code easier to read by having access to the log whenever and wherever rather than being forced to retrieve it every time it's needed.
Example
This example shows a variety of ways in which to create a logger. The reccommended way is to declare a static (Shared in Visual Basic) Logger member at the top of your class and use Reflection to get the current type as demonstrated. This way is reusable in that you can copy and paste it into the top of every class.
// Reusable (cut-n-paste) declaration you can put at the top of every class (recommended).
private static Logger log = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );

// Will retieve a logger named the same as the full type name (i.e. "Your.Assembly.TypeName").
Logger log = LogManager.GetLogger( this.GetType() );

// Will retrieve a logger by a specific name (not recommended).
Logger log = LogManager.GetLogger("some_unique_name");
' Reusable (cut-n-paste) declaration you can put at the top of every class (recommended).
Private Shared log As Logger = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType )

' Will retieve a logger named the same as the full type name (i.e. "Your.Assembly.TypeName").
Dim log As Logger = LogManager.GetLogger( this.GetType() )

' Will retrieve a logger by a specific name (not recommended).
Dim log As Logger = LogManager.GetLogger("some_unique_name")

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Reference

LogManager Class
LogManager Members
Overload List

 

 


© 2010 Dovetail Software, Inc. - All rights reserved.
- Clarify, Amdocs, and related products and names are copyright and trademark of Amdocs, Inc.
- .NET, Visual Studio.NET, C#, Visual Basic and related products are trademark of Microsoft corporation.

Send comments on this topic.