C# Class Catel.Logging.LogManager

Log manager that allows external libraries to subscribe to logging of Catel. The manager automatically adds an instance of the DebugLogListener to the list of listeners so the tracing is available in debug mode. To remove this listener, call ClearListeners before doing any initialization.
Exibir arquivo Open project: Catel/Catel

Public Methods

Method Description
AddDebugListener ( bool ignoreCatelLogging = false ) : ILogListener

Registers the default debug listener. Starting with Catel 2.4, the debug listener is no longer attached for performance reasons. To register the debug listener, call this method. When an instance of the DebugLogListener is already registered, the existing instance is returned.

AddListener ( ILogListener listener ) : void

Adds a log listener which will receive all log events. This method does not check whether the listener is already added to the list of registered listeners.

ClearListeners ( ) : void

Clears all the current listeners.

FlushAll ( ) : void

Flushes all listeners that implement the IBatchLogListener by calling IBatchLogListener.Flush.

GetListeners ( ) : IEnumerable

Gets all the currently registered log listeners.

GetLogger ( Type type ) : ILog

Gets the logger for the specified type.

IsListenerRegistered ( ILogListener listener ) : bool

Determines whether the specified listener is already registered or not.

LoadListenersFromConfiguration ( Configuration configuration, Assembly assembly = null ) : void

Loads the listeners from the specified configuration.

LoadListenersFromConfigurationFile ( string configurationFilePath, Assembly assembly = null ) : void

Loads the listeners from the specified configuration file.

RemoveListener ( ILogListener listener ) : void

Removes the a log listener which will stop receiving all log events.

Private Methods

Method Description
FlushAllAsync ( ) : System.Threading.Tasks.Task
GetCurrentClassLogger ( ) : ILog
GetThreadSafeLogListeners ( ) : List

Gets the current log listeners in a thread-safe manner.

IsListenerInterested ( ILogListener listener, LogEvent logEvent ) : bool

Determines whether the specified listener is interested in the log event.

LogManager ( ) : System

Initializes static members of the LogManager class.

OnLogMessage ( object sender, LogMessageEventArgs e ) : void

Called when one of the logs has written a log message.

Method Details

AddDebugListener() public static method

Registers the default debug listener. Starting with Catel 2.4, the debug listener is no longer attached for performance reasons. To register the debug listener, call this method. When an instance of the DebugLogListener is already registered, the existing instance is returned.
public static AddDebugListener ( bool ignoreCatelLogging = false ) : ILogListener
ignoreCatelLogging bool
return ILogListener

AddListener() public static method

Adds a log listener which will receive all log events. This method does not check whether the listener is already added to the list of registered listeners.
The is null.
public static AddListener ( ILogListener listener ) : void
listener ILogListener The listener.
return void

ClearListeners() public static method

Clears all the current listeners.
public static ClearListeners ( ) : void
return void

FlushAll() public static method

Flushes all listeners that implement the IBatchLogListener by calling IBatchLogListener.Flush.
public static FlushAll ( ) : void
return void

GetListeners() public static method

Gets all the currently registered log listeners.
public static GetListeners ( ) : IEnumerable
return IEnumerable

GetLogger() public static method

Gets the logger for the specified type.
The is null.
public static GetLogger ( Type type ) : ILog
type System.Type The type.
return ILog

IsListenerRegistered() public static method

Determines whether the specified listener is already registered or not.
The is null.
public static IsListenerRegistered ( ILogListener listener ) : bool
listener ILogListener The listener.
return bool

LoadListenersFromConfiguration() public static method

Loads the listeners from the specified configuration.
public static LoadListenersFromConfiguration ( Configuration configuration, Assembly assembly = null ) : void
configuration System.Configuration.Configuration The configuration.
assembly System.Reflection.Assembly The assembly to determine product info. If null, the entry assembly will be used.
return void

LoadListenersFromConfigurationFile() public static method

Loads the listeners from the specified configuration file.
public static LoadListenersFromConfigurationFile ( string configurationFilePath, Assembly assembly = null ) : void
configurationFilePath string The configuration file path.
assembly System.Reflection.Assembly The assembly to determine product info. If null, the entry assembly will be used.
return void

RemoveListener() public static method

Removes the a log listener which will stop receiving all log events.
The is null.
public static RemoveListener ( ILogListener listener ) : void
listener ILogListener The listener.
return void