C# Class Adf.Base.Logging.FlatFileLogProvider

Provides functionality to log a messages or exception into a flat file. This class does not use any logging frameworks and impliments ILogProvider interface.
Inheritance: ILogProvider
Datei anzeigen Open project: NLADP/ADF

Public Methods

Method Description
FlatFileLogProvider ( ) : System

Initializes a new instance of the FlatFileLogProvider class with no argument. Note that the logfile path should be mentioned in web.config file key="FlatFileLogPath" before initializing the object.

Log ( Exception exception, IUser user ) : void

Log the exception messages with frames on the call stack at the time the current exception was thrown.

Log ( LogLevel level, string message, IUser user ) : void

Log the error message as per the specified log level.

Log ( string message, IUser user ) : void

Log the specified error messages with current date.

Private Methods

Method Description
GetDateForFilename ( ) : string

Provides a string with current date in the format yyyyMMdd. Used to create the file name with current date.

GetDateForMessage ( ) : string

Provides a string having current date in a format yyyy-MM-dd HH:mm:ss. Use the current date time for writing message in log file.

IsAllowed ( LogLevel level ) : bool

Checks a given log level with configuartion loglevel.

OpenWriter ( ) : StreamWriter

Creates a System.IO.StreamWriter that appends or create UTF-8 encoded text to an existing or newly created file respectively.

Method Details

FlatFileLogProvider() public method

Initializes a new instance of the FlatFileLogProvider class with no argument. Note that the logfile path should be mentioned in web.config file key="FlatFileLogPath" before initializing the object.
public FlatFileLogProvider ( ) : System
return System

Log() public method

Log the exception messages with frames on the call stack at the time the current exception was thrown.
public Log ( Exception exception, IUser user ) : void
exception System.Exception The exception of that will logged.
user IUser The Adf.Core.IDomainObject object - not in use.
return void

Log() public method

Log the error message as per the specified log level.
public Log ( LogLevel level, string message, IUser user ) : void
level Adf.Core.Logging.LogLevel The Adf.Core.LogLevel that defines the comparison with configuration loglevel.
message string The error messages which will logged.
user IUser The Adf.Core.IDomainObject object - not in use.
return void

Log() public method

Log the specified error messages with current date.
public Log ( string message, IUser user ) : void
message string The error messages which will logged.
user IUser The Adf.Core.IDomainObject object - not in use.
return void