Easy Log Library

Easy Log Library

Released 6 years ago , Last update 6 years ago

EasyLog is a simple logging tool for the .Net framework

About EasyLog

EasyLog is a simple logging tool for for the .Net framework, and is designed to be easy to use, easy to configure and easy to extend.

Feature:

  1. Easy to use
  2. Easy to configure
  3. Easy to extend
  4. Configurable at runtime without modifying the application binary.
  5. Filter the message by level

1. Easy to Use
Code just like :

Log.Debug("Debug Message"); //write a debug level message
Log.Error("Error Message"); //write a error level message
Log.Error("Error Message", ex); //write a error level message and log the exception
Log.LogMessage("Error Message", Level.Error); //write a message with specipfy level
Log.LogMessage("Fatal Message", Level.Fatal, ex);//write a message with specipfy level and log the

2. Easy to Configurate
Default it is not need to configurate.
The default configuration is:
EasyLog.LogLevel is Error.
EasyLog.LogType is EasyLog.FileLog type.
EasyLog.FileLog.FilePathFormat is "~/log/{0:yyyy-MM-dd}.log", it will generate one log file per day.
EasyLog.FileLog.MaxLogLength is 10M, it will limit the content length to 10M.
It is suitable for deployment.
Below is equal configuration in application configuration file

<appSettings>
    <!--LogLevel: All, Debug, Info, Warn, Error, Fatal, Off -->
    <add key="EasyLog.LogLevel" value="Error"/>
    <!--LogType: the type of the loger, default is EasyLog.FileLog, like 'Namespace.ClassName, AssemblyName' -->
    <add key="EasyLog.LogType" value="EasyLog.FileLog, EasyLog"/>

    <!--FileLog.FilePathFormat: default format is ~/log/{0:yyyy-MM-dd}.log -->
    <add key="EasyLog.FileLog.FilePathFormat" value="~/log/{0:yyyy-MM-dd}.log"/>
    <!--FileLog.MaxLogLength: max file content length, default is 10M  -->
    <add key="EasyLog.FileLog.MaxLogLength" value="10M"/>
</appSettings>

3. Easy to Extend
See How to Extend it?

4. Configurable at runtime without modifying the application binary.
it use appSettings to store configuration in application configuration file. it is optional, you can change it.

5. Filter the message by level
level: DEBUG < INFO < WARN < ERROR < FATAL Default level is error, it will filter debug, info and warn level message.

6. How to Extend it?
it is easy to extend it, add a class that implemented the interface ILog, and configure it in the appSettings just like

<add key="EasyLog.LogType" value="EasyLogTest.ConsoleLog, EasyLogTest"/>

Example usage:

using EasyLog;
using System.Collections.Specialized;
namespace EasyLogTest
{
    public class ConsoleLog : ILog
    {
        public void ConfigLogger(NameValueCollection properties)
        {

        }

        public void LogMessage(object message, Level level, Exception ex)
        {
            StringBuilder messageBuilder = new StringBuilder();
            FormatMessage(messageBuilder, message, level, ex);
            Console.Write(messageBuilder);
        }

        public void FormatMessage(StringBuilder builder, object message, Level level, Exception e)
        {
            builder.Append("\tConsoleLog ");
            builder.Append(DateTime.Now);
            builder.Append((" [" + level.ToString().ToUpper() + "] ").PadRight(9));
            builder.Append(message);

            if (e != null)
            {
                builder.Append(Environment.NewLine).Append(e.ToString());
            }
            builder.AppendLine();
        }        
    }
}

Pricing

14 day 14-day money-back guarantee

$4.99

Personal License with Source Code

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

  • 6 months support

1 license From » $4.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
No comments have been posted yet.