Class LogManager
- Namespace
- Dynamicweb.Logging
- Assembly
- Dynamicweb.Logging.dll
The log manager takes care of the logging engine and creates a log manager instance if it is missing.
Use Current.GetLogger(string) to get a logging instance.
Log files are by default stored in /Files/System/Logs/{LogName} folder.
public class LogManager
- Inheritance
-
LogManager
- Inherited Members
Examples
namespace Dynamicweb.Logging.Examples
{
/// <summary>
/// The Class LoggerSample provides logging functionality.
/// </summary>
public class LoggerSample
{
private ILogger _logger = null;
/// <summary>
/// Initializes new LoggerSample instance.
/// </summary>
/// <param name="logName">The log name, which is used for log files location.</param>
/// <remarks>Log files are by default stored in /Files/System/Logs/{LogName} folder.</remarks>
public LoggerSample(string logName)
{
LogName = logName;
}
/// <summary>
/// Gets the logger instance.
/// </summary>
private ILogger Logger
{
get
{
if (_logger == null) {
_logger = LogManager.Current.GetLogger(LogName);
}
return _logger;
}
}
/// <summary>
/// Gets or sets The log name, which is used for log files location.
/// </summary>
public string LogName { get; set; }
/// <summary>
/// Logs an information message.
/// </summary>
/// <param name="message">The information message to be logged.</param>
public void LogMessge(string message)
{
Logger.Info(message);
}
/// <summary>
/// Logs an error message.
/// </summary>
/// <param name="message">The error message to be logged.</param>
public void LogError(string message)
{
Logger.Error(message);
}
}
}
Constructors
LogManager(ILoggerProvider)
Creates loggerManager instance injecting logProvider object
public LogManager(ILoggerProvider logProvider)
Parameters
logProvider
ILoggerProvider
Properties
Current
Gets or sets current LogManager instance for file logging
public static LogManager Current { get; set; }
Property Value
System
Gets a system LogManager instance for event logging
public static LogManager System { get; }
Property Value
Methods
DisableTracing()
Disables tracing
public void DisableTracing()
EnableTracing()
Enables tracing
public void EnableTracing()
GetLogger(string)
Gets logger using its name
public ILogger GetLogger(string name)
Parameters
name
string- Name as string
Returns
GetLogger(string, string)
Gets logger instance using its name and identifier
public ILogger GetLogger(string name, string identifier)
Parameters
Returns
ResetGlobalLogThreshold()
Resets global log threshold
public void ResetGlobalLogThreshold()
SetGlobalLogThreshold(LogLevel)
Sets global log threshold level
public void SetGlobalLogThreshold(LogLevel level)